From 78eba23d1233e9d240b4ccef6dcb64d66c4db91b Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 24 Aug 2023 13:44:15 +0200 Subject: [PATCH 001/137] refs #6156 new field --- .../00-ModifyProc_ticket_canAdvance.sql | 128 ++++++++++++++++++ .../back/methods/ticket/getTicketsAdvance.js | 11 +- modules/ticket/front/advance/index.html | 12 +- modules/ticket/front/future/locale/es.yml | 1 + 4 files changed, 140 insertions(+), 12 deletions(-) create mode 100644 db/changes/233601/00-ModifyProc_ticket_canAdvance.sql diff --git a/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql b/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql new file mode 100644 index 000000000..b0426711f --- /dev/null +++ b/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql @@ -0,0 +1,128 @@ +CREATE TABLE IF NOT EXISTS `vn`.`ticketCanAdvanceConfig` ( + `id` INT auto_increment NULL, + `destinationOrder` INT NULL, + CONSTRAINT `ticketCanAdvanceConfig_PK` PRIMARY KEY (id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `vn`.`ticketCanAdvanceConfig` + SET `destinationOrder` = 5; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. + * + * @param vDateFuture Fecha de los tickets que se quieren adelantar. + * @param vDateToAdvance Fecha a cuando se quiere adelantar. + * @param vWarehouseFk Almacén + */ + DECLARE vDateInventory DATE; + + SELECT inventoried INTO vDateInventory FROM config; + + CREATE OR REPLACE TEMPORARY TABLE tStock + (itemFk INT PRIMARY KEY, amount INT) + ENGINE = MEMORY; + + INSERT INTO tStock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; + + CREATE OR REPLACE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT dest.*, + origin.* + FROM ( + SELECT s.ticketFk futureId, + t.workerFk, + t.shipped futureShipped, + t.totalWithVat futureTotalWithVat, + st.name futureState, + t.addressFk futureAddressFk, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM((s.quantity <= IFNULL(tst.amount,0))) hasStock, + st.classColor futureClassColor, + ( + count(s.id) - + SUM((s.quantity <= IFNULL(tst.amount,0))) + ) notMovableLines, + ( + count(s.id) = + SUM((s.quantity <= IFNULL(tst.amount,0))) + ) isFullMovable + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tStock tst ON tst.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) origin + JOIN ( + SELECT t.id, + t.addressFk, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t.shipped, + t.totalWithVat, + am.name agency, + CAST(SUM(litros) AS DECIMAL(10,0)) liters, + CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, + st.classColor, + IF(HOUR(t.shipped), + HOUR(t.shipped), + COALESCE(HOUR(zc.hour),HOUR(z.hour)) + ) preparation + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN ticketCanAdvanceConfig + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) + AND t.warehouseFk = vWarehouseFk + AND st.order <= destinationOrder + GROUP BY t.id + ) dest ON dest.addressFk = origin.futureAddressFk + WHERE origin.hasStock != 0; + + DROP TEMPORARY TABLE tStock; +END$$ +DELIMITER ; diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index ec9314db2..5ad5152b9 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -110,13 +110,12 @@ module.exports = Self => { stmt = new ParameterizedSQL( `CALL vn.ticket_canAdvance(?,?,?)`, - [args.dateFuture, args.dateToAdvance, args.warehouseFk]); + [args.dateFuture, args.dateToAdvance, args.warehouseFk] + ); stmts.push(stmt); - stmt = new ParameterizedSQL(` - SELECT f.* - FROM tmp.filter f`); + stmt = new ParameterizedSQL(`SELECT f.* FROM tmp.filter f`); stmt.merge(conn.makeWhere(filter.where)); @@ -124,9 +123,7 @@ module.exports = Self => { stmt.merge(conn.makeLimit(filter)); const ticketsIndex = stmts.push(stmt) - 1; - stmts.push( - `DROP TEMPORARY TABLE - tmp.filter`); + stmts.push(`DROP TEMPORARY TABLE tmp.filter`); const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index e6f16c965..8c50325fa 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -32,8 +32,8 @@ - Destination - Origin + Destination + Origin @@ -43,8 +43,7 @@ check-field="checked"> - - + ID @@ -54,6 +53,9 @@ IPT + + Preparation + State @@ -120,6 +122,7 @@ {{::ticket.ipt | dashIfEmpty}} + {{::ticket.preparation | dashIfEmpty}} @@ -164,7 +167,6 @@ {{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}} - diff --git a/modules/ticket/front/future/locale/es.yml b/modules/ticket/front/future/locale/es.yml index 9fceea111..3645ad8ac 100644 --- a/modules/ticket/front/future/locale/es.yml +++ b/modules/ticket/front/future/locale/es.yml @@ -14,3 +14,4 @@ Success: Tickets movidos correctamente IPT: Encajado Origin Date: Fecha origen Destination Date: Fecha destino +Preparation: Preparación From d1214a998abd7636d862f0813634412f944ef184 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 6 Jun 2024 07:01:55 +0200 Subject: [PATCH 002/137] feat: login refs #6868 --- .../account/back/methods/account/login-app.js | 88 +++++++++++++++++++ modules/account/back/models/account.js | 1 + 2 files changed, 89 insertions(+) create mode 100644 modules/account/back/methods/account/login-app.js diff --git a/modules/account/back/methods/account/login-app.js b/modules/account/back/methods/account/login-app.js new file mode 100644 index 000000000..18543f90e --- /dev/null +++ b/modules/account/back/methods/account/login-app.js @@ -0,0 +1,88 @@ +const {setDefaultHighWaterMark} = require('form-data'); +const {setLocale} = require('i18n'); + +module.exports = Self => { + Self.remoteMethodCtx('loginApp', { + description: 'Login a user with username/email and password', + accepts: [ + { + arg: 'user', + type: 'String', + description: 'The user name or email', + required: true + }, { + arg: 'password', + type: 'String', + description: 'The password' + }, { + arg: 'deviceId', + type: 'String', + description: 'Device id' + }, { + arg: 'android_id', + type: 'String', + description: 'Android id' + }, { + arg: 'versionApp', + type: 'String', + description: 'Version app' + }, { + arg: 'nameApp', + type: 'String', + description: 'Version app' + }, { + arg: 'serialNumber', + type: 'String', + description: 'Serial number' + } + + ], + returns: { + type: 'object', + root: true + }, + http: { + path: `/loginApp`, + verb: 'POST' + } + }); + + Self.loginApp = async(ctx, user, password, deviceId, android_id, versionApp, nameApp, options) => { + const models = Self.app.models; + + const login = await Self.app.models.VnUser.signIn(ctx, user, password, options); + + const userId = login.user; + + const query = + `INSERT IGNORE INTO operator (workerFk) + VALUES (?);`; + + const insertOperator = await Self.rawSql(query, [userId], options); + + const [serialNumber] = await models.DeviceProductionUser.findOne({ + where: {id: '100'} + }); + + const insertDeviceLog = await models.DeviceLog.create( + { + 'android_id': android_id, + 'userFk': userId, + 'versionApp': versionApp, + 'nameApp': nameApp, + 'serialNumber': [serialNumber] + }, + options + ); + + const queryDeviceCheck = + `CALL device_checkLogin(?, ?)`; + + const [queryDeviceCheckLogin] = await Self.rawSql(queryDeviceCheck, [userId, android_id], options); + + if (!queryDeviceCheckLogin.vIsAuthorized) + throw new UserError('User not authorized'); + + return insertDeviceLog; + }; +}; diff --git a/modules/account/back/models/account.js b/modules/account/back/models/account.js index ceb26053c..f89d3079e 100644 --- a/modules/account/back/models/account.js +++ b/modules/account/back/models/account.js @@ -10,6 +10,7 @@ module.exports = Self => { require('../methods/account/logout')(Self); require('../methods/account/change-password')(Self); require('../methods/account/set-password')(Self); + require('../methods/account/login-app')(Self); Self.setUnverifiedPassword = async(id, pass, options) => { const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options); From 5c3ce40bbdfba57fa06f7b86f0cf4eebf23484bb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 11 Jun 2024 07:12:47 +0200 Subject: [PATCH 003/137] feat login-app refs #6868 --- .../account/back/methods/account/login-app.js | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/modules/account/back/methods/account/login-app.js b/modules/account/back/methods/account/login-app.js index 18543f90e..3ade88fb8 100644 --- a/modules/account/back/methods/account/login-app.js +++ b/modules/account/back/methods/account/login-app.js @@ -49,40 +49,44 @@ module.exports = Self => { Self.loginApp = async(ctx, user, password, deviceId, android_id, versionApp, nameApp, options) => { const models = Self.app.models; + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); - const login = await Self.app.models.VnUser.signIn(ctx, user, password, options); + await models.Account.login(ctx, user, password, myOptions); - const userId = login.user; + const userId = ctx.req.accessToken.userId; - const query = - `INSERT IGNORE INTO operator (workerFk) - VALUES (?);`; + const isUserInOperator = await models.Operator.findById(userId); + if (!isUserInOperator) + await models.Operator.create({'workerFk': userId}); - const insertOperator = await Self.rawSql(query, [userId], options); + const device = await models.DeviceProduction.findById(deviceId); - const [serialNumber] = await models.DeviceProductionUser.findOne({ - where: {id: '100'} - }); + // const [serialNumber] = await models.DeviceProductionUser.findOne({ + // where: {id: '100'} + // }); - const insertDeviceLog = await models.DeviceLog.create( - { - 'android_id': android_id, - 'userFk': userId, - 'versionApp': versionApp, - 'nameApp': nameApp, - 'serialNumber': [serialNumber] - }, - options - ); + // const insertDeviceLog = await models.DeviceLog.create( + // { + // 'android_id': android_id, + // 'userFk': userId, + // 'versionApp': versionApp, + // 'nameApp': nameApp, + // 'serialNumber': [serialNumber] + // }, + // options + // ); - const queryDeviceCheck = - `CALL device_checkLogin(?, ?)`; + // const queryDeviceCheck = + // `CALL device_checkLogin(?, ?)`; - const [queryDeviceCheckLogin] = await Self.rawSql(queryDeviceCheck, [userId, android_id], options); + // const [queryDeviceCheckLogin] = await Self.rawSql(queryDeviceCheck, [userId, android_id], options); - if (!queryDeviceCheckLogin.vIsAuthorized) - throw new UserError('User not authorized'); + // if (!queryDeviceCheckLogin.vIsAuthorized) + // throw new UserError('User not authorized'); - return insertDeviceLog; + // return insertDeviceLog; + return []; }; }; From 52b82603d22d4214282eaa216945423d6274ca86 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 13 Jun 2024 10:40:37 +0200 Subject: [PATCH 004/137] feat login-app refs #6868 --- .../account/back/methods/account/login-app.js | 54 +++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/modules/account/back/methods/account/login-app.js b/modules/account/back/methods/account/login-app.js index 3ade88fb8..5392f8eb2 100644 --- a/modules/account/back/methods/account/login-app.js +++ b/modules/account/back/methods/account/login-app.js @@ -1,5 +1,4 @@ -const {setDefaultHighWaterMark} = require('form-data'); -const {setLocale} = require('i18n'); +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('loginApp', { @@ -53,20 +52,55 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - await models.Account.login(ctx, user, password, myOptions); + const login = await models.Account.login(ctx, user, password, myOptions); const userId = ctx.req.accessToken.userId; - const isUserInOperator = await models.Operator.findById(userId); - if (!isUserInOperator) - await models.Operator.create({'workerFk': userId}); + const resultCheckLogin = + await Self.rawSql('CALL vn.device_checkLogin(?, ?);', + [userId, android_id], myOptions); - const device = await models.DeviceProduction.findById(deviceId); + const [{vIsAuthorized, vMessage}] = resultCheckLogin[0]; - // const [serialNumber] = await models.DeviceProductionUser.findOne({ - // where: {id: '100'} - // }); + if (!vIsAuthorized) + throw new UserError('Not authorized'); + const isUserInOperator = await models.Operator.findOne({ + where: { + workerFk: userId + } + }); + + if (!isUserInOperator){ + await models.Operator.create({ 'workerFk': userId }); + + const getDataUser = await models.Operator.findOne({ + where: { + workerFk: userId + } + }); + + const resultDevice = await models.DeviceProduction.findOne({ + where: { + android_id: android_id + } + }); + + if (resultDevice) + serialNumber = resultDevice.serialNumber ?? ''; + + await models.DeviceLog.create({ + 'android_id': android_id, + 'userFk': userId, + 'nameApp': nameApp, + 'versionApp': versionApp, + 'serialNumber': serialNumber + }); + + + + console.log(vIsAuthorized); + console.log(vMessage); // const insertDeviceLog = await models.DeviceLog.create( // { // 'android_id': android_id, From 9d5d62afafd846b2f64989a24fb10f1d594964ed Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 17 Jun 2024 13:56:58 +0200 Subject: [PATCH 005/137] feat newLogin refs #6868 --- .../account/back/methods/account/login-app.js | 111 +++++++++--------- .../methods/account/specs/login-app.spec.js | 20 ++++ modules/account/back/models/account.json | 9 +- 3 files changed, 82 insertions(+), 58 deletions(-) create mode 100644 modules/account/back/methods/account/specs/login-app.spec.js diff --git a/modules/account/back/methods/account/login-app.js b/modules/account/back/methods/account/login-app.js index 5392f8eb2..b18226bd2 100644 --- a/modules/account/back/methods/account/login-app.js +++ b/modules/account/back/methods/account/login-app.js @@ -2,23 +2,20 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('loginApp', { - description: 'Login a user with username/email and password', + description: 'Login a user with username and password for app', accepts: [ { arg: 'user', type: 'String', - description: 'The user name or email', + description: 'The user name', required: true }, { arg: 'password', type: 'String', + required: true, description: 'The password' }, { - arg: 'deviceId', - type: 'String', - description: 'Device id' - }, { - arg: 'android_id', + arg: 'androidId', type: 'String', description: 'Android id' }, { @@ -29,11 +26,7 @@ module.exports = Self => { arg: 'nameApp', type: 'String', description: 'Version app' - }, { - arg: 'serialNumber', - type: 'String', - description: 'Serial number' - } + }, ], returns: { @@ -46,7 +39,7 @@ module.exports = Self => { } }); - Self.loginApp = async(ctx, user, password, deviceId, android_id, versionApp, nameApp, options) => { + Self.loginApp = async(ctx, user, password, android_id, versionApp, nameApp, options) => { const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') @@ -54,14 +47,16 @@ module.exports = Self => { const login = await models.Account.login(ctx, user, password, myOptions); - const userId = ctx.req.accessToken.userId; + const {id: userId} = await models.VnUser.findOne({ + where: { + name: user + } + }); - const resultCheckLogin = + const [[{vIsAuthorized, vMessage}]] = await Self.rawSql('CALL vn.device_checkLogin(?, ?);', [userId, android_id], myOptions); - const [{vIsAuthorized, vMessage}] = resultCheckLogin[0]; - if (!vIsAuthorized) throw new UserError('Not authorized'); @@ -69,25 +64,14 @@ module.exports = Self => { where: { workerFk: userId } - }); + }, myOptions); - if (!isUserInOperator){ - await models.Operator.create({ 'workerFk': userId }); - - const getDataUser = await models.Operator.findOne({ - where: { - workerFk: userId - } - }); + if (!isUserInOperator) + await models.Operator.create({'workerFk': userId}); - const resultDevice = await models.DeviceProduction.findOne({ - where: { - android_id: android_id - } - }); - - if (resultDevice) - serialNumber = resultDevice.serialNumber ?? ''; + const serialNumber = (await models.DeviceProduction.findOne({ + where: {android_id: android_id} + }, myOptions))?.serialNumber ?? ''; await models.DeviceLog.create({ 'android_id': android_id, @@ -95,32 +79,45 @@ module.exports = Self => { 'nameApp': nameApp, 'versionApp': versionApp, 'serialNumber': serialNumber - }); + }, myOptions); + ctx.req.accessToken = {userId}; + const getDataUser = await models.VnUser.getCurrentUserData(ctx); - + const getDataOperator = await models.Operator.findOne({ + where: {workerFk: userId}, + fields: ['numberOfWagons', 'warehouseFk', 'itemPackingTypeFk', 'sectorFk', 'sector', + 'trainFk', 'train', 'labelerFk', 'printer'], + include: [ + { + relation: 'sector', + scope: { + fields: ['warehouseFk', 'description'], + } + }, { + relation: 'printer', + scope: { + fields: ['name'], + } + }, { + relation: 'train', + scope: { + fields: ['name'], + } + } - console.log(vIsAuthorized); - console.log(vMessage); - // const insertDeviceLog = await models.DeviceLog.create( - // { - // 'android_id': android_id, - // 'userFk': userId, - // 'versionApp': versionApp, - // 'nameApp': nameApp, - // 'serialNumber': [serialNumber] - // }, - // options - // ); + ] + }, myOptions); - // const queryDeviceCheck = - // `CALL device_checkLogin(?, ?)`; + const getVersion = await models.MobileAppVersionControl.getVersion(ctx, nameApp); - // const [queryDeviceCheckLogin] = await Self.rawSql(queryDeviceCheck, [userId, android_id], options); - - // if (!queryDeviceCheckLogin.vIsAuthorized) - // throw new UserError('User not authorized'); - - // return insertDeviceLog; - return []; + const combinedResult = { + ...login, + ...getDataOperator.__data, + ...getDataUser.__data, + ...getVersion, + message: vMessage, + serialNumber, + }; + return combinedResult; }; }; diff --git a/modules/account/back/methods/account/specs/login-app.spec.js b/modules/account/back/methods/account/specs/login-app.spec.js new file mode 100644 index 000000000..527429435 --- /dev/null +++ b/modules/account/back/methods/account/specs/login-app.spec.js @@ -0,0 +1,20 @@ +const {models} = require('vn-loopback/server/server'); + +describe('Account loginApp()', () => { + fit('should throw an error when user/password is wrong', async() => { + let req = models.Account.loginApp('user', 'pass'); + + await expectAsync(req).toBeRejected(); + }); + + fit('should return data from user', async() => { + let user = 'employee'; + let password = 'nightmare'; + let androidId = 'androidid11234567890'; + let nameApp = 'warehouse'; + let versionApp = '10'; + + let req = models.Account.loginApp(user, password, androidId, nameApp, versionApp); + await expectAsync(req).toBeResolved(); + }); +}); diff --git a/modules/account/back/models/account.json b/modules/account/back/models/account.json index 6c2784696..466b2bc04 100644 --- a/modules/account/back/models/account.json +++ b/modules/account/back/models/account.json @@ -31,6 +31,13 @@ "principalId": "$everyone", "permission": "ALLOW" }, + { + "property": "loginApp", + "accessType": "EXECUTE", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + }, { "property": "logout", "accessType": "EXECUTE", @@ -46,4 +53,4 @@ "permission": "ALLOW" } ] -} +} \ No newline at end of file From 0ab620b4854006a36882dcbc683fd759a94a2860 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 17 Jun 2024 16:50:00 +0200 Subject: [PATCH 006/137] feat newLogin refs #6868 --- modules/account/back/methods/account/login-app.js | 1 + modules/account/back/methods/account/specs/login-app.spec.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/account/back/methods/account/login-app.js b/modules/account/back/methods/account/login-app.js index b18226bd2..dc2708cbf 100644 --- a/modules/account/back/methods/account/login-app.js +++ b/modules/account/back/methods/account/login-app.js @@ -1,3 +1,4 @@ +const {ConsoleMessage} = require('puppeteer'); const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { diff --git a/modules/account/back/methods/account/specs/login-app.spec.js b/modules/account/back/methods/account/specs/login-app.spec.js index 527429435..90ce39f68 100644 --- a/modules/account/back/methods/account/specs/login-app.spec.js +++ b/modules/account/back/methods/account/specs/login-app.spec.js @@ -1,8 +1,9 @@ const {models} = require('vn-loopback/server/server'); describe('Account loginApp()', () => { + const ctx = {req: {accessToken: {}}}; fit('should throw an error when user/password is wrong', async() => { - let req = models.Account.loginApp('user', 'pass'); + let req = models.Account.loginApp(ctx, 'user', 'pass', 'androidid11234567890', 'warehouse', '10'); await expectAsync(req).toBeRejected(); }); @@ -14,7 +15,7 @@ describe('Account loginApp()', () => { let nameApp = 'warehouse'; let versionApp = '10'; - let req = models.Account.loginApp(user, password, androidId, nameApp, versionApp); + let req = models.Account.loginApp(ctx, user, password, androidId, nameApp, versionApp); await expectAsync(req).toBeResolved(); }); }); From c6da9e72e022c4101247b019887414b44c902693 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 17 Jun 2024 16:53:06 +0200 Subject: [PATCH 007/137] feat newLogin refs #6868 --- modules/account/back/methods/account/login-app.js | 2 +- .../back/methods/account/specs/login-app.spec.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/account/back/methods/account/login-app.js b/modules/account/back/methods/account/login-app.js index dc2708cbf..83c727f1a 100644 --- a/modules/account/back/methods/account/login-app.js +++ b/modules/account/back/methods/account/login-app.js @@ -1,4 +1,4 @@ -const {ConsoleMessage} = require('puppeteer'); + const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { diff --git a/modules/account/back/methods/account/specs/login-app.spec.js b/modules/account/back/methods/account/specs/login-app.spec.js index 90ce39f68..fc05cd726 100644 --- a/modules/account/back/methods/account/specs/login-app.spec.js +++ b/modules/account/back/methods/account/specs/login-app.spec.js @@ -3,19 +3,19 @@ const {models} = require('vn-loopback/server/server'); describe('Account loginApp()', () => { const ctx = {req: {accessToken: {}}}; fit('should throw an error when user/password is wrong', async() => { - let req = models.Account.loginApp(ctx, 'user', 'pass', 'androidid11234567890', 'warehouse', '10'); + const req = models.Account.loginApp(ctx, 'user', 'pass', 'androidid11234567890', 'warehouse', '10'); await expectAsync(req).toBeRejected(); }); fit('should return data from user', async() => { - let user = 'employee'; - let password = 'nightmare'; - let androidId = 'androidid11234567890'; - let nameApp = 'warehouse'; - let versionApp = '10'; + const user = 'employee'; + const password = 'nightmare'; + const androidId = 'androidid11234567890'; + const nameApp = 'warehouse'; + const versionApp = '10'; - let req = models.Account.loginApp(ctx, user, password, androidId, nameApp, versionApp); + const req = models.Account.loginApp(ctx, user, password, androidId, nameApp, versionApp); await expectAsync(req).toBeResolved(); }); }); From 4880d1497fe807721f094ac53fba1dbc29556ff5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 18 Jun 2024 08:40:33 +0200 Subject: [PATCH 008/137] feat: refs #6727 Added util logClean --- db/routines/util/events/log_clean.sql | 8 ++++ db/routines/util/procedures/log_clean.sql | 41 +++++++++++++++++++ .../11107-pinkAspidistra/00-firstScript.sql | 30 ++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 db/routines/util/events/log_clean.sql create mode 100644 db/routines/util/procedures/log_clean.sql create mode 100644 db/versions/11107-pinkAspidistra/00-firstScript.sql diff --git a/db/routines/util/events/log_clean.sql b/db/routines/util/events/log_clean.sql new file mode 100644 index 000000000..8447069e6 --- /dev/null +++ b/db/routines/util/events/log_clean.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`log_clean` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-07-09 00:30:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL util.log_clean$$ +DELIMITER ; diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql new file mode 100644 index 000000000..1401b5dd8 --- /dev/null +++ b/db/routines/util/procedures/log_clean.sql @@ -0,0 +1,41 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`log_clean`() +BEGIN +/** + * Hace limpieza de los datos de las tablas log, + * dejando únicamente los días de retención configurados. + */ + DECLARE vSchemaName VARCHAR(65); + DECLARE vTableName VARCHAR(65); + DECLARE vRetentionDays INT; + DECLARE vDated DATE; + DECLARE vDone BOOL; + + DECLARE vQueue CURSOR FOR + SELECT schemaName, tableName, retentionDays + FROM logClean + ORDER BY `order`; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vQueue; + l: LOOP + SET vDone = FALSE; + FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays; + + SET vSchemaName = util.quoteIdentifier(vSchemaName); + SET vTableName = util.quoteIdentifier(vTableName); + SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; + + IF vDone THEN + LEAVE l; + END IF; + + CALL util.exec(CONCAT( + 'DELETE FROM ', vSchemaName , '.', vTableName, + " WHERE creationDate < '", vDated, "'" + )); + END LOOP; + CLOSE vQueue; +END$$ +DELIMITER ; diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql new file mode 100644 index 000000000..e702da21e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -0,0 +1,30 @@ +CREATE OR REPLACE TABLE `util`.`logClean` ( + `schemaName` varchar(64) NOT NULL, + `tableName` varchar(64) NOT NULL, + `retentionDays` int(11) NOT NULL, + `order` int(11) DEFAULT NULL, + PRIMARY KEY (`schemaName`,`tableName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `util`.`logClean` (`schemaName`, `tableName`, `retentionDays`, `order`) + VALUES + ('account', 'roleLog', 'xxx', NULL), + ('account', 'userLog', 'xxx', NULL), + ('vn', 'entryLog', 'xxx', NULL), + ('vn', 'clientLog', 'xxx', NULL), + ('vn', 'itemLog', 'xxx', NULL), + ('vn', 'shelvingLog', 'xxx', NULL), + ('vn', 'workerLog', 'xxx', NULL), + ('vn', 'deviceProductionLog', 'xxx', NULL), + ('vn', 'zoneLog', 'xxx', NULL), + ('vn', 'rateLog', 'xxx', NULL), + ('vn', 'ticketLog', 'xxx', NULL), + ('vn', 'agencyLog', 'xxx', NULL), + ('vn', 'userLog', 'xxx', NULL), + ('vn', 'routeLog', 'xxx', NULL), + ('vn', 'claimLog', 'xxx', NULL), + ('vn', 'supplierLog', 'xxx', NULL), + ('vn', 'invoiceInLog', 'xxx', NULL), + ('vn', 'travelLog', 'xxx', NULL), + ('vn', 'packingSiteDeviceLog', 'xxx', NULL), + ('vn', 'parkingLog', 'xxx', NULL); From 2d3311b824ea299b9cef4cbfad161c5125f8c12c Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 18 Jun 2024 13:44:39 +0200 Subject: [PATCH 009/137] refs #6898 fix supplier remove --- .../01_summary_and_descriptor.spec.js | 79 ------ e2e/paths/13-supplier/02_basic_data.spec.js | 67 ----- e2e/paths/13-supplier/03_fiscal_data.spec.js | 56 ----- e2e/paths/13-supplier/04_billing_data.spec.js | 52 ---- e2e/paths/13-supplier/05_address.spec.js | 79 ------ e2e/paths/13-supplier/06_contact.spec.js | 89 ------- modules/supplier/front/account/index.html | 86 ------- modules/supplier/front/account/index.js | 66 ----- modules/supplier/front/account/index.spec.js | 98 -------- modules/supplier/front/account/locale/en.yml | 1 - modules/supplier/front/account/locale/es.yml | 6 - .../supplier/front/address/create/index.html | 109 -------- .../supplier/front/address/create/index.js | 74 ------ .../front/address/create/index.spec.js | 102 -------- .../supplier/front/address/edit/index.html | 104 -------- modules/supplier/front/address/edit/index.js | 62 ----- .../supplier/front/address/edit/index.spec.js | 39 --- .../supplier/front/address/index/index.html | 64 ----- modules/supplier/front/address/index/index.js | 46 ---- .../front/address/index/index.spec.js | 34 --- .../supplier/front/address/index/style.scss | 21 -- modules/supplier/front/address/locale/es.yml | 18 -- .../front/agency-term/create/index.html | 77 ------ .../front/agency-term/create/index.js | 26 -- .../front/agency-term/create/index.spec.js | 28 --- .../front/agency-term/index/index.html | 91 ------- .../supplier/front/agency-term/index/index.js | 36 --- .../front/agency-term/index/index.spec.js | 37 --- .../supplier/front/agency-term/locale/es.yml | 9 - modules/supplier/front/basic-data/index.html | 62 ----- modules/supplier/front/basic-data/index.js | 10 - .../supplier/front/basic-data/locale/es.yml | 5 - .../supplier/front/billing-data/index.html | 66 ----- modules/supplier/front/billing-data/index.js | 28 --- .../supplier/front/billing-data/locale/es.yml | 1 - modules/supplier/front/card/index.html | 5 - modules/supplier/front/card/index.js | 48 ---- .../front/consumption-search-panel/index.html | 67 ----- .../front/consumption-search-panel/index.js | 7 - .../consumption-search-panel/locale/es.yml | 7 - modules/supplier/front/consumption/index.html | 97 ------- modules/supplier/front/consumption/index.js | 88 ------- .../supplier/front/consumption/index.spec.js | 110 -------- .../supplier/front/consumption/locale/es.yml | 2 - modules/supplier/front/contact/index.html | 84 ------- modules/supplier/front/contact/index.js | 27 -- modules/supplier/front/contact/style.scss | 10 - modules/supplier/front/create/index.html | 30 --- modules/supplier/front/create/index.js | 23 -- .../front/descriptor-popover/index.html | 3 - .../front/descriptor-popover/index.js | 9 - modules/supplier/front/descriptor/index.html | 66 ----- modules/supplier/front/descriptor/index.js | 80 ------ .../supplier/front/descriptor/index.spec.js | 65 ----- .../supplier/front/descriptor/locale/es.yml | 8 - modules/supplier/front/fiscal-data/index.html | 237 ------------------ modules/supplier/front/fiscal-data/index.js | 86 ------- .../supplier/front/fiscal-data/index.spec.js | 109 -------- .../supplier/front/fiscal-data/locale/es.yml | 8 - modules/supplier/front/index.js | 20 -- modules/supplier/front/index/index.html | 64 ----- modules/supplier/front/index/index.js | 18 -- modules/supplier/front/index/locale/es.yml | 6 - modules/supplier/front/log/index.html | 1 - modules/supplier/front/log/index.js | 7 - modules/supplier/front/main/index.html | 17 -- modules/supplier/front/main/index.js | 10 +- modules/supplier/front/routes.json | 142 +---------- .../supplier/front/search-panel/index.html | 46 ---- modules/supplier/front/search-panel/index.js | 7 - .../supplier/front/search-panel/locale/es.yml | 4 - modules/supplier/front/summary/index.html | 172 ------------- modules/supplier/front/summary/index.js | 30 --- modules/supplier/front/summary/index.spec.js | 32 --- modules/supplier/front/summary/locale/es.yml | 12 - modules/supplier/front/summary/style.scss | 7 - 76 files changed, 10 insertions(+), 3689 deletions(-) delete mode 100644 e2e/paths/13-supplier/01_summary_and_descriptor.spec.js delete mode 100644 e2e/paths/13-supplier/02_basic_data.spec.js delete mode 100644 e2e/paths/13-supplier/03_fiscal_data.spec.js delete mode 100644 e2e/paths/13-supplier/04_billing_data.spec.js delete mode 100644 e2e/paths/13-supplier/05_address.spec.js delete mode 100644 e2e/paths/13-supplier/06_contact.spec.js delete mode 100644 modules/supplier/front/account/index.html delete mode 100644 modules/supplier/front/account/index.js delete mode 100644 modules/supplier/front/account/index.spec.js delete mode 100644 modules/supplier/front/account/locale/en.yml delete mode 100644 modules/supplier/front/account/locale/es.yml delete mode 100644 modules/supplier/front/address/create/index.html delete mode 100644 modules/supplier/front/address/create/index.js delete mode 100644 modules/supplier/front/address/create/index.spec.js delete mode 100644 modules/supplier/front/address/edit/index.html delete mode 100644 modules/supplier/front/address/edit/index.js delete mode 100644 modules/supplier/front/address/edit/index.spec.js delete mode 100644 modules/supplier/front/address/index/index.html delete mode 100644 modules/supplier/front/address/index/index.js delete mode 100644 modules/supplier/front/address/index/index.spec.js delete mode 100644 modules/supplier/front/address/index/style.scss delete mode 100644 modules/supplier/front/address/locale/es.yml delete mode 100644 modules/supplier/front/agency-term/create/index.html delete mode 100644 modules/supplier/front/agency-term/create/index.js delete mode 100644 modules/supplier/front/agency-term/create/index.spec.js delete mode 100644 modules/supplier/front/agency-term/index/index.html delete mode 100644 modules/supplier/front/agency-term/index/index.js delete mode 100644 modules/supplier/front/agency-term/index/index.spec.js delete mode 100644 modules/supplier/front/agency-term/locale/es.yml delete mode 100644 modules/supplier/front/basic-data/index.html delete mode 100644 modules/supplier/front/basic-data/index.js delete mode 100644 modules/supplier/front/basic-data/locale/es.yml delete mode 100644 modules/supplier/front/billing-data/index.html delete mode 100644 modules/supplier/front/billing-data/index.js delete mode 100644 modules/supplier/front/billing-data/locale/es.yml delete mode 100644 modules/supplier/front/card/index.html delete mode 100644 modules/supplier/front/card/index.js delete mode 100644 modules/supplier/front/consumption-search-panel/index.html delete mode 100644 modules/supplier/front/consumption-search-panel/index.js delete mode 100644 modules/supplier/front/consumption-search-panel/locale/es.yml delete mode 100644 modules/supplier/front/consumption/index.html delete mode 100644 modules/supplier/front/consumption/index.js delete mode 100644 modules/supplier/front/consumption/index.spec.js delete mode 100644 modules/supplier/front/consumption/locale/es.yml delete mode 100644 modules/supplier/front/contact/index.html delete mode 100644 modules/supplier/front/contact/index.js delete mode 100644 modules/supplier/front/contact/style.scss delete mode 100644 modules/supplier/front/create/index.html delete mode 100644 modules/supplier/front/create/index.js delete mode 100644 modules/supplier/front/descriptor-popover/index.html delete mode 100644 modules/supplier/front/descriptor-popover/index.js delete mode 100644 modules/supplier/front/descriptor/index.html delete mode 100644 modules/supplier/front/descriptor/index.js delete mode 100644 modules/supplier/front/descriptor/index.spec.js delete mode 100644 modules/supplier/front/descriptor/locale/es.yml delete mode 100644 modules/supplier/front/fiscal-data/index.html delete mode 100644 modules/supplier/front/fiscal-data/index.js delete mode 100644 modules/supplier/front/fiscal-data/index.spec.js delete mode 100644 modules/supplier/front/fiscal-data/locale/es.yml delete mode 100644 modules/supplier/front/index/index.html delete mode 100644 modules/supplier/front/index/index.js delete mode 100644 modules/supplier/front/index/locale/es.yml delete mode 100644 modules/supplier/front/log/index.html delete mode 100644 modules/supplier/front/log/index.js delete mode 100644 modules/supplier/front/search-panel/index.html delete mode 100644 modules/supplier/front/search-panel/index.js delete mode 100644 modules/supplier/front/search-panel/locale/es.yml delete mode 100644 modules/supplier/front/summary/index.html delete mode 100644 modules/supplier/front/summary/index.js delete mode 100644 modules/supplier/front/summary/index.spec.js delete mode 100644 modules/supplier/front/summary/locale/es.yml delete mode 100644 modules/supplier/front/summary/style.scss diff --git a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js deleted file mode 100644 index a2e194e42..000000000 --- a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier summary & descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'supplier'); - await page.accessToSearchResult('1'); - }); - - afterAll(async() => { - await browser.close(); - }); - - // summary - it('should reach the second entry summary section', async() => { - await page.waitForState('supplier.card.summary'); - }); - - it(`should confirm there's data on the summary header`, async() => { - const result = await page.waitToGetProperty(selectors.supplierSummary.header, 'innerText'); - - expect(result).toContain('PLANTS SL - 1'); - }); - - it(`should confirm there's data on the summary basic data`, async() => { - const result = await page.waitToGetProperty(selectors.supplierSummary.basicDataId, 'innerText'); - - expect(result).toContain('Id 1'); - }); - - it(`should confirm there's data on the summary fiscal address`, async() => { - const result = await page.waitToGetProperty(selectors.supplierSummary.fiscalAddressTaxNumber, 'innerText'); - - expect(result).toContain('Tax number 06089160W'); - }); - - it(`should confirm there's data on the summary fiscal pay method`, async() => { - const result = await page.waitToGetProperty(selectors.supplierSummary.billingDataPayMethod, 'innerText'); - - expect(result).toContain('Pay method PayMethod one'); - }); - - // descriptor - it(`should confirm there's data on the descriptor`, async() => { - const result = await page.waitToGetProperty(selectors.supplierDescriptor.alias, 'innerText'); - - expect(result).toContain('Plants nick'); - }); - - it(`should navigate to the supplier's client summary using the icon client button`, async() => { - await page.waitToClick(selectors.supplierDescriptor.clientButton); - await page.waitForState('client.card.summary'); - }); - - it(`should navigate back to the supplier`, async() => { - await page.waitToClick(selectors.globalItems.homeButton); - await page.waitForState('home'); - await page.selectModule('supplier'); - await page.accessToSearchResult('1'); - await page.waitForState('supplier.card.summary'); - }); - - it(`should navigate back to suppliers but a different one this time`, async() => { - await page.waitToClick(selectors.globalItems.homeButton); - await page.waitForState('home'); - await page.selectModule('supplier'); - await page.accessToSearchResult('2'); - await page.waitForState('supplier.card.summary'); - }); - - it(`should check the client button isn't present since this supplier should not be a client`, async() => { - await page.waitForSelector(selectors.supplierDescriptor.clientButton, {visible: false}); - }); -}); diff --git a/e2e/paths/13-supplier/02_basic_data.spec.js b/e2e/paths/13-supplier/02_basic_data.spec.js deleted file mode 100644 index 710ebd8df..000000000 --- a/e2e/paths/13-supplier/02_basic_data.spec.js +++ /dev/null @@ -1,67 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('financial', 'supplier'); - await page.accessToSearchResult('1'); - await page.accessToSection('supplier.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the basic data', async() => { - await page.clearInput(selectors.supplierBasicData.alias); - await page.write(selectors.supplierBasicData.alias, 'Plants Nick SL'); - await page.waitToClick(selectors.supplierBasicData.isReal); - await page.waitToClick(selectors.supplierBasicData.isActive); - await page.waitToClick(selectors.supplierBasicData.isPayMethodChecked); - await page.write(selectors.supplierBasicData.notes, 'Some notes'); - - await page.waitToClick(selectors.supplierBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section', async() => { - await page.reloadSection('supplier.card.basicData'); - }); - - it('should check the alias was edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBasicData.alias, 'value'); - - expect(result).toEqual('Plants Nick SL'); - }); - - it('should check the isReal checkbox is now checked', async() => { - const result = await page.checkboxState(selectors.supplierBasicData.isReal); - - expect(result).toBe('checked'); - }); - - it('should check the isActive checkbox is now unchecked', async() => { - const result = await page.checkboxState(selectors.supplierBasicData.isActive); - - expect(result).toBe('unchecked'); - }); - - it('should check the isPayMethodChecked checkbox is now unchecked', async() => { - const result = await page.checkboxState(selectors.supplierBasicData.isPayMethodChecked); - - expect(result).toBe('unchecked'); - }); - - it('should check the notes were edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBasicData.notes, 'value'); - - expect(result).toEqual('Some notes'); - }); -}); diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js deleted file mode 100644 index ccd9d7809..000000000 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier fiscal data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'supplier'); - await page.accessToSearchResult('2'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should attempt to edit the fiscal data and check data iss saved', async() => { - await page.accessToSection('supplier.card.fiscalData'); - - const form = 'vn-supplier-fiscal-data form'; - const values = { - province: null, - country: null, - postcode: null, - city: 'Valencia', - socialName: 'FARMER KING SL', - taxNumber: '12345678Z', - account: '0123456789', - sageWithholding: 'retencion estimacion objetiva', - sageTaxType: 'operaciones no sujetas' - }; - - const errorMessage = await page.sendForm(form, { - taxNumber: 'Wrong tax number' - }); - const message = await page.sendForm(form, values); - - await page.reloadSection('supplier.card.fiscalData'); - const formValues = await page.fetchForm(form, Object.keys(values)); - - expect(errorMessage.text).toContain('Invalid Tax number'); - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual({ - province: 'Province one', - country: 'España', - postcode: '46000', - city: 'Valencia', - socialName: 'FARMER KING SL', - taxNumber: '12345678Z', - account: '0123456789', - sageWithholding: 'RETENCION ESTIMACION OBJETIVA', - sageTaxType: 'Operaciones no sujetas' - }); - }); -}); diff --git a/e2e/paths/13-supplier/04_billing_data.spec.js b/e2e/paths/13-supplier/04_billing_data.spec.js deleted file mode 100644 index d3cb6dcab..000000000 --- a/e2e/paths/13-supplier/04_billing_data.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier billing data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'supplier'); - await page.accessToSearchResult('442'); - await page.accessToSection('supplier.card.billingData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the billing data', async() => { - await page.autocompleteSearch(selectors.supplierBillingData.payMethod, 'PayMethod with IBAN'); - await page.autocompleteSearch(selectors.supplierBillingData.payDem, '10'); - await page.clearInput(selectors.supplierBillingData.payDay); - await page.write(selectors.supplierBillingData.payDay, '19'); - await page.waitToClick(selectors.supplierBillingData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section', async() => { - await page.reloadSection('supplier.card.billingData'); - }); - - it('should check the pay method was edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBillingData.payMethod, 'value'); - - expect(result).toEqual('PayMethod with IBAN'); - }); - - it('should check the payDem was edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBillingData.payDem, 'value'); - - expect(result).toEqual('10'); - }); - - it('should check the pay day was edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBillingData.payDay, 'value'); - - expect(result).toEqual('19'); - }); -}); diff --git a/e2e/paths/13-supplier/05_address.spec.js b/e2e/paths/13-supplier/05_address.spec.js deleted file mode 100644 index 5bccba3ee..000000000 --- a/e2e/paths/13-supplier/05_address.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier address path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'supplier'); - await page.accessToSearchResult('1'); - await page.accessToSection('supplier.card.address.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should count the addresses before creating one', async() => { - const count = await page.countElement(selectors.supplierAddress.anyAddress); - - expect(count).toEqual(2); - }); - - it('should open the new address form by clicking the add button', async() => { - await page.waitToClick(selectors.supplierAddress.newAddress); - await page.waitForState('supplier.card.address.create'); - }); - - it('should create a new address', async() => { - await page.write(selectors.supplierAddress.newNickname, 'Darkest dungeon'); - await page.write(selectors.supplierAddress.newStreet, 'Wayne manor'); - await page.write(selectors.supplierAddress.newPostcode, '46000'); - await page.write(selectors.supplierAddress.newCity, 'Valencia'); - await page.autocompleteSearch(selectors.supplierAddress.newProvince, 'Province one'); - await page.write(selectors.supplierAddress.newPhone, '888888888'); - await page.write(selectors.supplierAddress.newMobile, '444444444'); - await page.waitToClick(selectors.supplierAddress.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should have been redirected to the addresses index', async() => { - await page.waitForState('supplier.card.address.index'); - }); - - it('should count the addresses and find one more now', async() => { - const count = await page.countElement(selectors.supplierAddress.anyAddress); - - expect(count).toEqual(3); - }); - - it('should open the edit address form by clicking the new address', async() => { - await page.waitToClick(selectors.supplierAddress.thirdAddress); - await page.waitForState('supplier.card.address.edit'); - }); - - it('should edit the address', async() => { - await page.overwrite(selectors.supplierAddress.editNickname, 'Wayne manor'); - await page.overwrite(selectors.supplierAddress.editStreet, '1007 Mountain Drive'); - await page.overwrite(selectors.supplierAddress.editPostcode, '46000'); - await page.overwrite(selectors.supplierAddress.editCity, 'Valencia'); - await page.autocompleteSearch(selectors.supplierAddress.editProvince, 'Province one'); - await page.overwrite(selectors.supplierAddress.editPhone, '777777777'); - await page.overwrite(selectors.supplierAddress.editMobile, '555555555'); - await page.waitToClick(selectors.supplierAddress.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should check the address has now the expected data', async() => { - let thirdAddress = await page.waitToGetProperty(selectors.supplierAddress.thirdAddress, 'innerText'); - - expect(thirdAddress).toContain('Wayne manor'); - }); -}); diff --git a/e2e/paths/13-supplier/06_contact.spec.js b/e2e/paths/13-supplier/06_contact.spec.js deleted file mode 100644 index 60fd28f9c..000000000 --- a/e2e/paths/13-supplier/06_contact.spec.js +++ /dev/null @@ -1,89 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier contact path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'supplier'); - await page.accessToSearchResult('1'); - await page.accessToSection('supplier.card.contact'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should create a new contact', async() => { - await page.waitToClick(selectors.supplierContact.addNewContact); - await page.write(selectors.supplierContact.thirdContactName, 'The tester'); - await page.write(selectors.supplierContact.thirdContactPhone, '99 999 99 99'); - await page.write(selectors.supplierContact.thirdContactMobile, '555 55 55 55'); - await page.write(selectors.supplierContact.thirdContactEmail, 'testing@puppeteer.com'); - await page.write(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester'); - await page.waitToClick(selectors.supplierContact.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should reload the section and count the contacts`, async() => { - await page.reloadSection('supplier.card.contact'); - const result = await page.countElement(selectors.supplierContact.anyContact); - - expect(result).toEqual(3); - }); - - it(`should check the new contact name was saved correctly`, async() => { - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactName, 'value'); - - expect(result).toContain('The tester'); - }); - - it(`should check the new contact phone was saved correctly`, async() => { - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactPhone, 'value'); - - expect(result).toContain('99 999 99 99'); - }); - - it(`should check the new contact mobile was saved correctly`, async() => { - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactMobile, 'value'); - - expect(result).toContain('555 55 55 55'); - }); - - it(`should check the new contact email was saved correctly`, async() => { - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactEmail, 'value'); - - expect(result).toContain('testing@puppeteer.com'); - }); - - it(`should check the new contact note was saved correctly`, async() => { - await page.waitForTextInField(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester'); - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactNotes, 'value'); - - expect(result).toContain('the end to end integration tester'); - }); - - it(`should remove the created contact`, async() => { - await page.waitToClick(selectors.supplierContact.thirdContactDeleteButton, 'value'); - const result = await page.countElement(selectors.supplierContact.anyContact); - - expect(result).toEqual(2); - - await page.waitToClick(selectors.supplierContact.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should reload the section and count the amount of contacts went back to 2`, async() => { - await page.reloadSection('supplier.card.contact'); - const result = await page.countElement(selectors.supplierContact.anyContact); - - expect(result).toEqual(2); - }); -}); diff --git a/modules/supplier/front/account/index.html b/modules/supplier/front/account/index.html deleted file mode 100644 index a0b58c737..000000000 --- a/modules/supplier/front/account/index.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - -
- - - - - - {{bic}} {{name}} - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - \ No newline at end of file diff --git a/modules/supplier/front/account/index.js b/modules/supplier/front/account/index.js deleted file mode 100644 index 5629e65d3..000000000 --- a/modules/supplier/front/account/index.js +++ /dev/null @@ -1,66 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.include = { - relation: 'bankEntity', - scope: { - fields: ['countryFk', 'id', 'name', 'bic'] - } - }; - const filter = { - where: {code: 'wireTransfer'} - }; - - this.$http.get(`payMethods/findOne`, {filter}) - .then(res => { - this.wireTransferFk = res.data.id; - }); - } - - add() { - this.$.model.insert({ - supplierFk: this.$params.id - }); - } - - onAccept(data) { - const accounts = this.supplierAccounts; - const targetAccount = accounts[data.index]; - targetAccount.bankEntityFk = data.id; - } - - onSubmit() { - this.$.watcher.check(); - return this.$.model.save() - .then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - return this.card.reload(); - }) - .then(() => { - if (this.supplier.payMethodFk != this.wireTransferFk) - this.$.payMethodToTransfer.show(); - }); - } - - setWireTransfer() { - const params = { - id: this.$params.id, - payMethodFk: this.wireTransferFk - }; - const query = `Suppliers/${this.$params.id}`; - return this.$http.patch(query, params) - .then(() => this.$.watcher.notifySaved()); - } -} - -ngModule.vnComponent('vnSupplierAccount', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnSupplierCard' - } -}); diff --git a/modules/supplier/front/account/index.spec.js b/modules/supplier/front/account/index.spec.js deleted file mode 100644 index ad29d1abc..000000000 --- a/modules/supplier/front/account/index.spec.js +++ /dev/null @@ -1,98 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('Supplier Component vnSupplierAccount', () => { - let $scope; - let controller; - let $httpBackend; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - - $scope.bankEntity = { - open: () => {} - }; - - const $element = angular.element(''); - controller = $componentController('vnSupplierAccount', {$element, $scope}); - controller.supplierAccount = { - supplierFk: 442, - name: 'Verdnatura' - }; - })); - - describe('onAccept()', () => { - it('should set the created bank entity id into the target account', () => { - controller.supplierAccounts = [{}, {}, {}]; - - const data = { - id: 999, - index: 1 - }; - - controller.onAccept(data); - - const targetAccount = controller.supplierAccounts[data.index]; - - expect(targetAccount.bankEntityFk).toEqual(data.id); - }); - }); - - describe('onSubmit()', () => { - it(`should reload the card`, done => { - controller.card = {reload: () => {}}; - controller.$.payMethodToTransfer = {show: () => {}}; - jest.spyOn(controller.$.payMethodToTransfer, 'show'); - jest.spyOn(controller.$.model, 'save').mockReturnValue(new Promise(resolve => { - return resolve({ - id: 1234 - }); - })); - jest.spyOn(controller.card, 'reload').mockReturnValue(new Promise(resolve => { - return resolve({ - id: 1234 - }); - })); - - controller.wireTransferFk = 'a'; - controller.supplier = {payMethodFk: 'b'}; - controller.onSubmit().then(() => { - expect(controller.card.reload).toHaveBeenCalledWith(); - expect(controller.$.payMethodToTransfer.show).toHaveBeenCalled(); - done(); - }).catch(done.fail); - }); - }); - - describe('setWireTransfer()', () => { - it(`should make HTTP PATCH request to set wire transfer and call notifySaved`, () => { - const supplierId = 1; - const params = { - id: supplierId, - payMethodFk: 2 - }; - const response = { - data: {id: 2} - }; - const uri = 'payMethods/findOne?filter=%7B%22where%22:%7B%22code%22:%22wireTransfer%22%7D%7D'; - jest.spyOn($scope.watcher, 'notifySaved'); - - controller.$params.id = supplierId; - controller.wireTransferFk = 2; - controller.supplier = {payMethodFk: 1}; - $httpBackend.expectGET(uri).respond(response); - $httpBackend.expectPATCH(`Suppliers/${supplierId}`, params).respond(); - controller.setWireTransfer(); - $httpBackend.flush(); - - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - }); - }); -}); - diff --git a/modules/supplier/front/account/locale/en.yml b/modules/supplier/front/account/locale/en.yml deleted file mode 100644 index f41f5756a..000000000 --- a/modules/supplier/front/account/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -Beneficiary information: Name of the bank account holder if different from the provider \ No newline at end of file diff --git a/modules/supplier/front/account/locale/es.yml b/modules/supplier/front/account/locale/es.yml deleted file mode 100644 index f445a3fb8..000000000 --- a/modules/supplier/front/account/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -Bank entity: Entidad bancaria -swift: Swift BIC -Add account: Añadir cuenta -Beneficiary: Beneficiario -Beneficiary information: Nombre del titular de la cuenta bancaria en caso de ser diferente del proveedor -Do you want to change the pay method to wire transfer?: ¿Quieres modificar la forma de pago a transferencia? \ No newline at end of file diff --git a/modules/supplier/front/address/create/index.html b/modules/supplier/front/address/create/index.html deleted file mode 100644 index e3f883641..000000000 --- a/modules/supplier/front/address/create/index.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - -
- - - - - - - - - - - {{code}} - {{town.name}} ({{town.province.name}}, - {{town.province.country.name}}) - - - - - - - - - {{name}}, {{province.name}} - ({{province.country.name}}) - - - - {{name}} ({{country.name}}) - - - - - - - - - - - - - - -
- - - - diff --git a/modules/supplier/front/address/create/index.js b/modules/supplier/front/address/create/index.js deleted file mode 100644 index 21b845881..000000000 --- a/modules/supplier/front/address/create/index.js +++ /dev/null @@ -1,74 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.address = { - supplierFk: this.$params.id - }; - } - - onSubmit() { - this.$.watcher.submit().then(res => { - this.$state.go('supplier.card.address.index'); - }); - } - - get town() { - return this._town; - } - - // Town auto complete - set town(selection) { - this._town = selection; - - if (!selection) return; - - const province = selection.province; - const postcodes = selection.postcodes; - - if (!this.address.provinceFk) - this.address.provinceFk = province.id; - - if (postcodes.length === 1) - this.address.postalCode = postcodes[0].code; - } - - get postcode() { - return this._postcode; - } - - // Postcode auto complete - set postcode(selection) { - this._postcode = selection; - - if (!selection) return; - - const town = selection.town; - const province = town.province; - - if (!this.address.city) - this.address.city = town.name; - - if (!this.address.provinceFk) - this.address.provinceFk = province.id; - } - - onResponse(response) { - this.address.postalCode = response.code; - this.address.city = response.city; - this.address.provinceFk = response.provinceFk; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnSupplierAddressCreate', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/address/create/index.spec.js b/modules/supplier/front/address/create/index.spec.js deleted file mode 100644 index 026de3769..000000000 --- a/modules/supplier/front/address/create/index.spec.js +++ /dev/null @@ -1,102 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressCreate', () => { - let $scope; - let controller; - let $element; - let $state; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $state.params.id = '1234'; - $element = angular.element(''); - controller = $componentController('vnSupplierAddressCreate', {$element, $scope}); - controller.$.watcher = watcher; - controller.$.watcher.submit = () => { - return { - then: callback => { - callback({data: {id: 124}}); - } - }; - }; - controller.supplier = {id: 1}; - })); - - describe('onSubmit()', () => { - it('should perform a PATCH and then redirect to the main section', () => { - jest.spyOn(controller.$state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.address.index'); - }); - }); - - describe('town() setter', () => { - it(`should set provinceFk property`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [] - }; - - expect(controller.address.provinceFk).toEqual(1); - }); - - it(`should set provinceFk property and fill the postalCode if there's just one`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [{code: '46001'}] - }; - - expect(controller.address.provinceFk).toEqual(1); - expect(controller.address.postalCode).toEqual('46001'); - }); - }); - - describe('postcode() setter', () => { - it(`should set the town and province properties`, () => { - controller.postcode = { - townFk: 1, - code: 46001, - town: { - id: 1, - name: 'New York', - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - } - } - }; - - expect(controller.address.city).toEqual('New York'); - expect(controller.address.provinceFk).toEqual(1); - }); - }); - }); -}); diff --git a/modules/supplier/front/address/edit/index.html b/modules/supplier/front/address/edit/index.html deleted file mode 100644 index b966023da..000000000 --- a/modules/supplier/front/address/edit/index.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - -
- - - - - - - - - - - {{code}} - {{town.name}} ({{town.province.name}}, - {{town.province.country.name}}) - - - - - - - - - {{name}}, {{province.name}} - ({{province.country.name}}) - - - - {{name}} ({{country.name}}) - - - - - - - - - - - - - -
- - - - diff --git a/modules/supplier/front/address/edit/index.js b/modules/supplier/front/address/edit/index.js deleted file mode 100644 index 4c7450666..000000000 --- a/modules/supplier/front/address/edit/index.js +++ /dev/null @@ -1,62 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - this.$.watcher.submit() - .then(() => this.$state.go('supplier.card.address.index')); - } - - get town() { - return this._town; - } - - // Town auto complete - set town(selection) { - const oldValue = this._town; - this._town = selection; - - if (!selection || !oldValue) return; - - const province = selection.province; - const postcodes = selection.postcodes; - - if (!this.address.provinceFk) - this.address.provinceFk = province.id; - - if (!this.address.postalCode && postcodes.length === 1) - this.address.postalCode = postcodes[0].code; - } - - get postcode() { - return this._postcode; - } - - // Postcode auto complete - set postcode(selection) { - const oldValue = this._postcode; - this._postcode = selection; - - if (!selection || !oldValue) return; - - const town = selection.town; - const province = town.province; - - if (!this.address.city) - this.address.city = town.name; - - if (!this.address.provinceFk) - this.address.provinceFk = province.id; - } - - onResponse(response) { - this.address.postalCode = response.code; - this.address.city = response.city; - this.address.provinceFk = response.provinceFk; - } -} - -ngModule.vnComponent('vnSupplierAddressEdit', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/address/edit/index.spec.js b/modules/supplier/front/address/edit/index.spec.js deleted file mode 100644 index 991163baa..000000000 --- a/modules/supplier/front/address/edit/index.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressEdit', () => { - let $scope; - let controller; - let $element; - let $state; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $state.params.addressId = '1'; - $element = angular.element(''); - controller = $componentController('vnSupplierAddressEdit', {$element, $scope}); - controller.address = {id: 1}; - controller.$.watcher = watcher; - controller.$.watcher.submit = () => { - return { - then: callback => { - callback({data: {id: 124}}); - } - }; - }; - })); - - describe('onSubmit()', () => { - it('should perform a PATCH and then redirect to the main section', () => { - jest.spyOn(controller.$state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.address.index'); - }); - }); - }); -}); diff --git a/modules/supplier/front/address/index/index.html b/modules/supplier/front/address/index/index.html deleted file mode 100644 index cb7b3d56c..000000000 --- a/modules/supplier/front/address/index/index.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/supplier/front/address/index/index.js b/modules/supplier/front/address/index/index.js deleted file mode 100644 index c3985a0c1..000000000 --- a/modules/supplier/front/address/index/index.js +++ /dev/null @@ -1,46 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - fields: [ - 'id', - 'nickname', - 'street', - 'city', - 'provinceFk', - 'phone', - 'mobile', - 'postalCode' - ], - order: ['nickname ASC'], - include: [{ - relation: 'province', - scope: { - fields: ['id', 'name'] - } - }] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {nickname: {like: `%${value}%`}}; - } - } -} -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnSupplierAddressIndex', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/address/index/index.spec.js b/modules/supplier/front/address/index/index.spec.js deleted file mode 100644 index 086d3a9fa..000000000 --- a/modules/supplier/front/address/index/index.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import './index'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressIndex', () => { - let controller; - let $scope; - let $stateParams; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$stateParams_) => { - $stateParams = _$stateParams_; - $stateParams.id = 1; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnSupplierAddressIndex', {$element, $scope}); - controller.supplier = {id: 1}; - })); - - describe('exprBuilder()', () => { - it('should return a filter based on a search by id', () => { - const filter = controller.exprBuilder('search', '123'); - - expect(filter).toEqual({id: '123'}); - }); - - it('should return a filter based on a search by name', () => { - const filter = controller.exprBuilder('search', 'Arkham Chemicals'); - - expect(filter).toEqual({nickname: {like: '%Arkham Chemicals%'}}); - }); - }); - }); -}); diff --git a/modules/supplier/front/address/index/style.scss b/modules/supplier/front/address/index/style.scss deleted file mode 100644 index 44ce07b3c..000000000 --- a/modules/supplier/front/address/index/style.scss +++ /dev/null @@ -1,21 +0,0 @@ -@import "variables"; -@import "./effects"; - -vn-supplier-address-index { - .address { - padding-bottom: $spacing-md; - - &:last-child { - padding-bottom: 0; - } - & > a { - @extend %clickable; - box-sizing: border-box; - display: flex; - align-items: center; - width: 100%; - color: inherit; - overflow: hidden; - } - } -} \ No newline at end of file diff --git a/modules/supplier/front/address/locale/es.yml b/modules/supplier/front/address/locale/es.yml deleted file mode 100644 index 30009fa87..000000000 --- a/modules/supplier/front/address/locale/es.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Index -Search by address: Buscar por dirección -You can search by address id or name: Puedes buscar por el id o nombre de la dirección - -# Create -Street address: Dirección postal -Postcode: Código postal -Town/City: Ciudad -Province: Provincia -Phone: Teléfono -Mobile: Móvil - -# Common -Fiscal name: Nombre fiscal -Street: Dirección fiscal -Addresses: Direcciones -New address: Nueva dirección -Edit address: Editar dirección \ No newline at end of file diff --git a/modules/supplier/front/agency-term/create/index.html b/modules/supplier/front/agency-term/create/index.html deleted file mode 100644 index 728e98146..000000000 --- a/modules/supplier/front/agency-term/create/index.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/supplier/front/agency-term/create/index.js b/modules/supplier/front/agency-term/create/index.js deleted file mode 100644 index 3f66ac5e9..000000000 --- a/modules/supplier/front/agency-term/create/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.supplierAgencyTerm = { - supplierFk: this.$params.id - }; - } - - onSubmit() { - this.$.watcher.submit().then(res => { - this.$state.go('supplier.card.agencyTerm.index'); - }); - } -} - -ngModule.vnComponent('vnSupplierAgencyTermCreate', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/agency-term/create/index.spec.js b/modules/supplier/front/agency-term/create/index.spec.js deleted file mode 100644 index 682e1cc58..000000000 --- a/modules/supplier/front/agency-term/create/index.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressCreate', () => { - let $scope; - let controller; - let $element; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $scope.watcher = watcher; - $element = angular.element(''); - controller = $componentController('vnSupplierAgencyTermCreate', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should redirect to 'supplier.card.agencyTerm.index' state`, () => { - jest.spyOn(controller.$state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.agencyTerm.index'); - }); - }); - }); -}); diff --git a/modules/supplier/front/agency-term/index/index.html b/modules/supplier/front/agency-term/index/index.html deleted file mode 100644 index 44c6deba9..000000000 --- a/modules/supplier/front/agency-term/index/index.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - diff --git a/modules/supplier/front/agency-term/index/index.js b/modules/supplier/front/agency-term/index/index.js deleted file mode 100644 index 9f77d686a..000000000 --- a/modules/supplier/front/agency-term/index/index.js +++ /dev/null @@ -1,36 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - include: - {relation: 'agency', - scope: { - fields: ['id', 'name'] - } - } - }; - } - - add() { - this.$.model.insert({}); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } -} - -ngModule.vnComponent('vnSupplierAgencyTermIndex', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/agency-term/index/index.spec.js b/modules/supplier/front/agency-term/index/index.spec.js deleted file mode 100644 index 3e9ea4c1e..000000000 --- a/modules/supplier/front/agency-term/index/index.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressCreate', () => { - let $scope; - let controller; - let $element; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - $element = angular.element(''); - controller = $componentController('vnSupplierAgencyTermIndex', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save values', () => { - jest.spyOn($scope.watcher, 'check'); - jest.spyOn($scope.watcher, 'notifySaved'); - jest.spyOn($scope.watcher, 'updateOriginalData'); - jest.spyOn($scope.model, 'save'); - - controller.onSubmit(); - - expect($scope.model.save).toHaveBeenCalledWith(); - expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect($scope.watcher.check).toHaveBeenCalledWith(); - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/supplier/front/agency-term/locale/es.yml b/modules/supplier/front/agency-term/locale/es.yml deleted file mode 100644 index cdbd7c2ca..000000000 --- a/modules/supplier/front/agency-term/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Minimum M3: M3 minimos -Package Price: Precio bulto -Km Price: Precio Km -M3 Price: Precio M3 -Route Price: Precio ruta -Minimum Km: Km minimos -Remove row: Eliminar fila -Add row: Añadir fila -New autonomous: Nuevo autónomo diff --git a/modules/supplier/front/basic-data/index.html b/modules/supplier/front/basic-data/index.html deleted file mode 100644 index fcdb2a522..000000000 --- a/modules/supplier/front/basic-data/index.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/supplier/front/basic-data/index.js b/modules/supplier/front/basic-data/index.js deleted file mode 100644 index 447118ebb..000000000 --- a/modules/supplier/front/basic-data/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnSupplierBasicData', { - template: require('./index.html'), - controller: Section, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/basic-data/locale/es.yml b/modules/supplier/front/basic-data/locale/es.yml deleted file mode 100644 index e965ffc2e..000000000 --- a/modules/supplier/front/basic-data/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Notes: Notas -Active: Activo -Verified: Verificado -PayMethodChecked: Método de pago validado -Responsible for approving invoices: Responsable de aprobar las facturas \ No newline at end of file diff --git a/modules/supplier/front/billing-data/index.html b/modules/supplier/front/billing-data/index.html deleted file mode 100644 index 238760c1a..000000000 --- a/modules/supplier/front/billing-data/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - -
- - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/supplier/front/billing-data/index.js b/modules/supplier/front/billing-data/index.js deleted file mode 100644 index 9d2863f64..000000000 --- a/modules/supplier/front/billing-data/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - get supplier() { - return this._supplier; - } - - set supplier(value) { - this._supplier = value; - } - - onSubmit() { - this.$.watcher.submit() - .then(() => this.card.reload()); - } -} - -ngModule.vnComponent('vnSupplierBillingData', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - }, - require: { - card: '^vnSupplierCard' - } -}); diff --git a/modules/supplier/front/billing-data/locale/es.yml b/modules/supplier/front/billing-data/locale/es.yml deleted file mode 100644 index d84d37f3a..000000000 --- a/modules/supplier/front/billing-data/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Pay day: Dia de pago \ No newline at end of file diff --git a/modules/supplier/front/card/index.html b/modules/supplier/front/card/index.html deleted file mode 100644 index 2c3c9df36..000000000 --- a/modules/supplier/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/supplier/front/card/index.js b/modules/supplier/front/card/index.js deleted file mode 100644 index 13fc3d52d..000000000 --- a/modules/supplier/front/card/index.js +++ /dev/null @@ -1,48 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: [ - { - relation: 'province', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'country', - scope: { - fields: ['id', 'name', 'code'] - } - }, - { - relation: 'payMethod', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'payDem', - scope: { - fields: ['id', 'payDem'] - } - }, - { - relation: 'client', - scope: { - fields: ['id', 'fi'] - } - } - ] - }; - return this.$http.get(`Suppliers/${this.$params.id}`, {filter}) - .then(response => this.supplier = response.data); - } -} - -ngModule.vnComponent('vnSupplierCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/consumption-search-panel/index.html b/modules/supplier/front/consumption-search-panel/index.html deleted file mode 100644 index 5cba11d3c..000000000 --- a/modules/supplier/front/consumption-search-panel/index.html +++ /dev/null @@ -1,67 +0,0 @@ -
-
- - - - - - - - - - - - - -
{{name}}
-
- {{category.name}} -
-
-
- - -
- - - - - - - - - -
-
diff --git a/modules/supplier/front/consumption-search-panel/index.js b/modules/supplier/front/consumption-search-panel/index.js deleted file mode 100644 index f6c63c55c..000000000 --- a/modules/supplier/front/consumption-search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnSupplierConsumptionSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/supplier/front/consumption-search-panel/locale/es.yml b/modules/supplier/front/consumption-search-panel/locale/es.yml deleted file mode 100644 index f136283f8..000000000 --- a/modules/supplier/front/consumption-search-panel/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Item id: Id artículo -From: Desde -To: Hasta -Campaign: Campaña -allSaints: Día de todos los Santos -valentinesDay: Día de San Valentín -mothersDay: Día de la madre \ No newline at end of file diff --git a/modules/supplier/front/consumption/index.html b/modules/supplier/front/consumption/index.html deleted file mode 100644 index e6c86abe3..000000000 --- a/modules/supplier/front/consumption/index.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - -
- - - - - - -
- - - - Entry - {{::entry.id}} - Date - {{::entry.shipped | date: 'dd/MM/yyyy'}} - Reference - {{::entry.invoiceNumber}} - - - - - - - {{::buy.itemName}} - - - -
- - -

{{::buy.subName}}

-
-
- - -
- {{::buy.quantity | dashIfEmpty}} - {{::buy.price | dashIfEmpty}} - {{::buy.total | dashIfEmpty}} - -
-
- - - - - - - - -
-
-
- - - - diff --git a/modules/supplier/front/consumption/index.js b/modules/supplier/front/consumption/index.js deleted file mode 100644 index 9af0d1747..000000000 --- a/modules/supplier/front/consumption/index.js +++ /dev/null @@ -1,88 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $, vnReport, vnEmail) { - super($element, $); - this.vnReport = vnReport; - this.vnEmail = vnEmail; - - this.setDefaultFilter(); - } - - setDefaultFilter() { - const minDate = Date.vnNew(); - minDate.setHours(0, 0, 0, 0); - minDate.setMonth(minDate.getMonth() - 2); - - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); - - this.filterParams = { - from: minDate, - to: maxDate - }; - } - - get reportParams() { - const userParams = this.$.model.userParams; - return Object.assign({ - authorization: this.vnToken.token, - recipientId: this.supplier.id - }, userParams); - } - - showReport() { - const path = `Suppliers/${this.supplier.id}/campaign-metrics-pdf`; - this.vnReport.show(path, this.reportParams); - } - - sendEmail() { - const params = { - filter: { - where: { - supplierFk: this.$params.id, - email: {neq: null} - }, - limit: 1 - } - }; - this.$http.get('SupplierContacts', params).then(({data}) => { - if (data.length) { - const contact = data[0]; - const params = Object.assign({ - recipient: contact.email - }, this.reportParams); - - const path = `Suppliers/${this.supplier.id}/campaign-metrics-email`; - this.vnEmail.send(path, params); - } else { - const message = this.$t(`This supplier doesn't have a contact with an email address`); - this.vnApp.showError(message); - } - }); - } - - getTotal(entry) { - if (entry.buys) { - let total = 0; - for (let buy of entry.buys) - total += buy.total; - - return total; - } - } -} - -Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; - -ngModule.vnComponent('vnSupplierConsumption', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - }, - require: { - card: '^vnSupplierCard' - } -}); diff --git a/modules/supplier/front/consumption/index.spec.js b/modules/supplier/front/consumption/index.spec.js deleted file mode 100644 index 0ac531a68..000000000 --- a/modules/supplier/front/consumption/index.spec.js +++ /dev/null @@ -1,110 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Supplier', () => { - describe('Component vnSupplierConsumption', () => { - let $scope; - let controller; - let $httpParamSerializer; - let $httpBackend; - const supplierId = 2; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { - $scope = $rootScope.$new(); - $httpParamSerializer = _$httpParamSerializer_; - $httpBackend = _$httpBackend_; - const $element = angular.element(' { - it('should call the window.open function', () => { - jest.spyOn(window, 'open').mockReturnThis(); - - const now = Date.vnNew(); - controller.$.model.userParams = { - from: now, - to: now - }; - - controller.showReport(); - - const expectedParams = { - recipientId: 2, - from: now, - to: now - }; - const serializedParams = $httpParamSerializer(expectedParams); - const path = `api/Suppliers/${supplierId}/campaign-metrics-pdf?${serializedParams}`; - - expect(window.open).toHaveBeenCalledWith(path); - }); - }); - - describe('sendEmail()', () => { - it('should throw an error', () => { - jest.spyOn(controller.vnApp, 'showError'); - - const expectedParams = { - filter: { - where: { - supplierFk: supplierId, - email: {neq: null} - }, - limit: 1 - } - }; - const serializedParams = $httpParamSerializer(expectedParams); - $httpBackend.expectGET(`SupplierContacts?${serializedParams}`).respond({}); - controller.sendEmail(); - $httpBackend.flush(); - - expect(controller.vnApp.showError) - .toHaveBeenCalledWith(`This supplier doesn't have a contact with an email address`); - }); - - it('should make a GET query sending the report', () => { - let serializedParams; - const params = { - filter: { - where: { - supplierFk: supplierId, - email: {neq: null} - }, - limit: 1 - } - }; - serializedParams = $httpParamSerializer(params); - $httpBackend.whenGET(`SupplierContacts?${serializedParams}`).respond([ - {id: 1, email: 'batman@gothamcity.com'} - ]); - - const now = Date.vnNew(); - controller.$.model.userParams = { - from: now, - to: now - }; - const expectedParams = { - recipient: 'batman@gothamcity.com', - from: now, - to: now - }; - - serializedParams = $httpParamSerializer(expectedParams); - const path = `Suppliers/${supplierId}/campaign-metrics-email`; - - $httpBackend.expect('POST', path).respond({}); - controller.sendEmail(); - $httpBackend.flush(); - }); - }); - }); -}); - diff --git a/modules/supplier/front/consumption/locale/es.yml b/modules/supplier/front/consumption/locale/es.yml deleted file mode 100644 index 08c2a22e5..000000000 --- a/modules/supplier/front/consumption/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Total entry: Total entrada -This supplier doesn't have a contact with an email address: Este proveedor no tiene ningún contacto con una dirección de email diff --git a/modules/supplier/front/contact/index.html b/modules/supplier/front/contact/index.html deleted file mode 100644 index 347e4261a..000000000 --- a/modules/supplier/front/contact/index.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - -
- -
- - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - - - -
\ No newline at end of file diff --git a/modules/supplier/front/contact/index.js b/modules/supplier/front/contact/index.js deleted file mode 100644 index 48db3d526..000000000 --- a/modules/supplier/front/contact/index.js +++ /dev/null @@ -1,27 +0,0 @@ -import ngModule from '../module'; -import './style.scss'; -import Section from 'salix/components/section'; - -class Controller extends Section { - add() { - this.$.model.insert({ - supplierFk: this.supplier.id - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } -} - -ngModule.vnComponent('vnSupplierContact', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/contact/style.scss b/modules/supplier/front/contact/style.scss deleted file mode 100644 index becc66dcf..000000000 --- a/modules/supplier/front/contact/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -@import "variables"; - - -.contact { - max-width: $width-lg; - margin-bottom: 10px; - padding-right: 10px; - padding-left: 10px; - border: 1px solid $color-spacer; -} diff --git a/modules/supplier/front/create/index.html b/modules/supplier/front/create/index.html deleted file mode 100644 index 1e051f3a8..000000000 --- a/modules/supplier/front/create/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - -
- - - - - - - - - - - - -
diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js deleted file mode 100644 index c33367dac..000000000 --- a/modules/supplier/front/create/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - onSubmit() { - this.$.watcher.submit().then( - json => { - this.$state.go(`supplier.card.fiscalData`, {id: json.data.id}); - } - ); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnSupplierCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/descriptor-popover/index.html b/modules/supplier/front/descriptor-popover/index.html deleted file mode 100644 index 874ba6708..000000000 --- a/modules/supplier/front/descriptor-popover/index.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/modules/supplier/front/descriptor-popover/index.js b/modules/supplier/front/descriptor-popover/index.js deleted file mode 100644 index a30aa4829..000000000 --- a/modules/supplier/front/descriptor-popover/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import ngModule from '../module'; -import DescriptorPopover from 'salix/components/descriptor-popover'; - -class Controller extends DescriptorPopover {} - -ngModule.vnComponent('vnSupplierDescriptorPopover', { - slotTemplate: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/descriptor/index.html b/modules/supplier/front/descriptor/index.html deleted file mode 100644 index af5be2537..000000000 --- a/modules/supplier/front/descriptor/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - -
- - - - - - - - - - - - -
-
- - - - -
- -
-
- - - \ No newline at end of file diff --git a/modules/supplier/front/descriptor/index.js b/modules/supplier/front/descriptor/index.js deleted file mode 100644 index f84b4ef92..000000000 --- a/modules/supplier/front/descriptor/index.js +++ /dev/null @@ -1,80 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get supplier() { - return this.entity; - } - - set supplier(value) { - this.entity = value; - } - - get entryFilter() { - if (!this.supplier) return null; - - const date = Date.vnNew(); - date.setHours(0, 0, 0, 0); - - const from = new Date(date.getTime()); - from.setDate(from.getDate() - 10); - - const to = new Date(date.getTime()); - to.setDate(to.getDate() + 10); - - return JSON.stringify({ - supplierFk: this.id, - from, - to - }); - } - - loadData() { - const filter = { - fields: [ - 'id', - 'name', - 'nickname', - 'nif', - 'payMethodFk', - 'payDemFk', - 'payDay', - 'isActive', - 'isReal', - 'isTrucker', - 'account' - ], - include: [ - { - relation: 'payMethod', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'payDem', - scope: { - fields: ['id', 'payDem'] - } - }, - { - relation: 'client', - scope: { - fields: ['id', 'fi'] - } - } - ] - }; - - return this.getData(`Suppliers/${this.id}`, {filter}) - .then(res => this.supplier = res.data); - } -} - -ngModule.vnComponent('vnSupplierDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/descriptor/index.spec.js b/modules/supplier/front/descriptor/index.spec.js deleted file mode 100644 index 12c3e43bc..000000000 --- a/modules/supplier/front/descriptor/index.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import './index.js'; - -describe('Supplier Component vnSupplierDescriptor', () => { - let $httpBackend; - let controller; - let $httpParamSerializer; - const supplier = {id: 1}; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier}); - })); - - describe('loadData()', () => { - it('should perform ask for the supplier', () => { - const filter = { - fields: [ - 'id', - 'name', - 'nickname', - 'nif', - 'payMethodFk', - 'payDemFk', - 'payDay', - 'isActive', - 'isReal', - 'isTrucker', - 'account' - ], - include: [ - { - relation: 'payMethod', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'payDem', - scope: { - fields: ['id', 'payDem'] - } - }, - { - relation: 'client', - scope: { - fields: ['id', 'fi'] - } - } - ] - }; - const serializedParams = $httpParamSerializer({filter}); - let query = `Suppliers/${controller.supplier.id}?${serializedParams}`; - jest.spyOn(controller, 'getData'); - - $httpBackend.expect('GET', query).respond({id: 1}); - controller.loadData(); - $httpBackend.flush(); - - expect(controller.getData).toHaveBeenCalledTimes(1); - }); - }); -}); diff --git a/modules/supplier/front/descriptor/locale/es.yml b/modules/supplier/front/descriptor/locale/es.yml deleted file mode 100644 index cf4a52393..000000000 --- a/modules/supplier/front/descriptor/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Tax number: NIF / CIF -All entries with current supplier: Todas las entradas con el proveedor actual -Go to client: Ir al cliente -Verified supplier: Proveedor verificado -Unverified supplier: Proveedor no verificado -Inactive supplier: Proveedor inactivo -Create invoiceIn: Crear factura recibida -Supplier name: Razón social diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html deleted file mode 100644 index 6455bf3fd..000000000 --- a/modules/supplier/front/fiscal-data/index.html +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - {{id}}: {{transaction}} - - - - - - - - - - - - - - {{code}} - {{town.name}} ({{town.province.name}}, - {{town.province.country.name}}) - - - - - - - - - - - {{name}}, {{province.name}} - ({{province.country.name}}) - - - - {{name}} ({{country.name}}) - - - - - - - - - - - - - - - - - - - -
- - - diff --git a/modules/supplier/front/fiscal-data/index.js b/modules/supplier/front/fiscal-data/index.js deleted file mode 100644 index 8a6a51249..000000000 --- a/modules/supplier/front/fiscal-data/index.js +++ /dev/null @@ -1,86 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - get province() { - return this._province; - } - - // Province auto complete - set province(selection) { - const oldValue = this._province; - this._province = selection; - - if (!selection || !oldValue) return; - - const country = selection.country; - - if (!this.supplier.countryFk) - this.supplier.countryFk = country.id; - } - - get town() { - return this._town; - } - - // Town auto complete - set town(selection) { - const oldValue = this._town; - this._town = selection; - - if (!selection || !oldValue) return; - - const province = selection.province; - const country = province.country; - const postcodes = selection.postcodes; - - if (!this.supplier.provinceFk) - this.supplier.provinceFk = province.id; - - if (!this.supplier.countryFk) - this.supplier.countryFk = country.id; - - if (!this.supplier.postCode && postcodes.length === 1) - this.supplier.postCode = postcodes[0].code; - } - - get postcode() { - return this._postcode; - } - - // Postcode auto complete - set postcode(selection) { - const oldValue = this._postcode; - this._postcode = selection; - - if (!selection || !oldValue) return; - - const town = selection.town; - const province = town.province; - const country = province.country; - - if (!this.supplier.city) - this.supplier.city = town.name; - - if (!this.supplier.provinceFk) - this.supplier.provinceFk = province.id; - - if (!this.supplier.countryFk) - this.supplier.countryFk = country.id; - } - - onResponse(response) { - this.supplier.postCode = response.code; - this.supplier.city = response.city; - this.supplier.provinceFk = response.provinceFk; - this.supplier.countryFk = response.countryFk; - } -} - -ngModule.vnComponent('vnSupplierFiscalData', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/fiscal-data/index.spec.js b/modules/supplier/front/fiscal-data/index.spec.js deleted file mode 100644 index 6fb135c08..000000000 --- a/modules/supplier/front/fiscal-data/index.spec.js +++ /dev/null @@ -1,109 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Supplier', () => { - describe('Component vnSupplierFiscalData', () => { - let $scope; - let $element; - let controller; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $scope.watcher = watcher; - $scope.watcher.orgData = {id: 1}; - $element = angular.element(''); - controller = $componentController('vnSupplierFiscalData', {$element, $scope}); - controller.card = {reload: () => {}}; - controller.supplier = { - id: 1, - name: 'Batman' - }; - - controller._province = {}; - controller._town = {}; - controller._postcode = {}; - })); - - describe('province() setter', () => { - it(`should set countryFk property`, () => { - controller.supplier.countryFk = null; - controller.province = { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }; - - expect(controller.supplier.countryFk).toEqual(2); - }); - }); - - describe('town() setter', () => { - it(`should set provinceFk property`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [] - }; - - expect(controller.supplier.provinceFk).toEqual(1); - }); - - it(`should set provinceFk property and fill the postalCode if there's just one`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [{code: '46001'}] - }; - - expect(controller.supplier.provinceFk).toEqual(1); - expect(controller.supplier.postCode).toEqual('46001'); - }); - }); - - describe('postcode() setter', () => { - it(`should set the town, provinceFk and contryFk properties`, () => { - controller.postcode = { - townFk: 1, - code: 46001, - town: { - id: 1, - name: 'New York', - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - } - } - }; - - expect(controller.supplier.city).toEqual('New York'); - expect(controller.supplier.provinceFk).toEqual(1); - expect(controller.supplier.countryFk).toEqual(2); - }); - }); - }); -}); diff --git a/modules/supplier/front/fiscal-data/locale/es.yml b/modules/supplier/front/fiscal-data/locale/es.yml deleted file mode 100644 index ee641231f..000000000 --- a/modules/supplier/front/fiscal-data/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Sage tax type: Tipo de impuesto Sage -Sage transaction type: Tipo de transacción Sage -Sage withholding: Retención Sage -Supplier activity: Actividad proveedor -Healt register: Pasaporte sanitario -Trucker: Transportista -When activating it, do not enter the country code in the ID field.: Al activarlo, no informar el código del país en el campo nif -The first two values are letters.: Los dos primeros valores son letras \ No newline at end of file diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index 9216d0781..a7209a0bd 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -1,23 +1,3 @@ export * from './module'; import './main'; -import './card'; -import './descriptor'; -import './descriptor-popover'; -import './index/'; -import './search-panel'; -import './summary'; -import './basic-data'; -import './fiscal-data'; -import './account'; -import './contact'; -import './log'; -import './consumption'; -import './consumption-search-panel'; -import './billing-data'; -import './address/index'; -import './address/create'; -import './address/edit'; -import './agency-term/index'; -import './agency-term/create'; -import './create/index'; diff --git a/modules/supplier/front/index/index.html b/modules/supplier/front/index/index.html deleted file mode 100644 index 49f38cb1b..000000000 --- a/modules/supplier/front/index/index.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/supplier/front/index/index.js b/modules/supplier/front/index/index.js deleted file mode 100644 index 77b2e8347..000000000 --- a/modules/supplier/front/index/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - openSummary(supplier, event) { - if (event.defaultPrevented) return; - event.preventDefault(); - event.stopPropagation(); - - this.supplierSelected = supplier; - this.$.dialogSummarySupplier.show(); - } -} - -ngModule.vnComponent('vnSupplierIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/index/locale/es.yml b/modules/supplier/front/index/locale/es.yml deleted file mode 100644 index ce06f462c..000000000 --- a/modules/supplier/front/index/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -Payment deadline: Plazo de pago -Pay day: Dia de pago -Account: Cuenta -Pay method: Metodo de pago -Tax number: Nif -New supplier: Nuevo proveedor \ No newline at end of file diff --git a/modules/supplier/front/log/index.html b/modules/supplier/front/log/index.html deleted file mode 100644 index 7895b585e..000000000 --- a/modules/supplier/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/supplier/front/log/index.js b/modules/supplier/front/log/index.js deleted file mode 100644 index 52a491c70..000000000 --- a/modules/supplier/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnSupplierLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/supplier/front/main/index.html b/modules/supplier/front/main/index.html index 04d7aa0ad..e69de29bb 100644 --- a/modules/supplier/front/main/index.html +++ b/modules/supplier/front/main/index.html @@ -1,17 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/supplier/front/main/index.js b/modules/supplier/front/main/index.js index 2fd870573..fd99cc0a2 100644 --- a/modules/supplier/front/main/index.js +++ b/modules/supplier/front/main/index.js @@ -1,7 +1,15 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Supplier extends ModuleMain {} +export default class Supplier extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`supplier/`); + } +} ngModule.vnComponent('vnSupplier', { controller: Supplier, diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 75b8213cb..ab0022ff9 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -36,146 +36,6 @@ "state": "supplier.index", "component": "vn-supplier-index", "description": "Suppliers" - }, - { - "url": "/:id", - "state": "supplier.card", - "abstract": true, - "component": "vn-supplier-card" - }, - { - "url": "/summary", - "state": "supplier.card.summary", - "component": "vn-supplier-summary", - "description": "Summary", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/create", - "state": "supplier.create", - "component": "vn-supplier-create", - "acl": ["administrative"], - "description": "New supplier" - }, - { - "url": "/basic-data", - "state": "supplier.card.basicData", - "component": "vn-supplier-basic-data", - "description": "Basic data", - "acl": ["administrative"], - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/fiscal-data", - "state": "supplier.card.fiscalData", - "component": "vn-supplier-fiscal-data", - "description": "Fiscal data", - "params": { - "supplier": "$ctrl.supplier" - }, - "acl": ["administrative"] - }, - { - "url" : "/log", - "state": "supplier.card.log", - "component": "vn-supplier-log", - "description": "Log" - }, - { - "url": "/contact", - "state": "supplier.card.contact", - "component": "vn-supplier-contact", - "description": "Contacts", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/agency-term", - "state": "supplier.card.agencyTerm", - "component": "ui-view", - "abstract": true - }, - { - "url": "/index", - "state": "supplier.card.agencyTerm.index", - "component": "vn-supplier-agency-term-index", - "description": "Agency Agreement", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/create", - "state": "supplier.card.agencyTerm.create", - "component": "vn-supplier-agency-term-create", - "description": "New autonomous", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/consumption?q", - "state": "supplier.card.consumption", - "component": "vn-supplier-consumption", - "description": "Consumption", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/billing-data", - "state": "supplier.card.billingData", - "component": "vn-supplier-billing-data", - "description": "Billing data", - "params": { - "supplier": "$ctrl.supplier" - }, - "acl": ["administrative"] - }, - { - "url": "/account", - "state": "supplier.card.account", - "component": "vn-supplier-account", - "description": "Accounts", - "params": { - "supplier": "$ctrl.supplier" - }, - "acl": ["administrative"] - }, - { - "url": "/address", - "state": "supplier.card.address", - "component": "ui-view", - "abstract": true - }, - { - "url": "/index?q", - "state": "supplier.card.address.index", - "component": "vn-supplier-address-index", - "description": "Addresses", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/create", - "state": "supplier.card.address.create", - "component": "vn-supplier-address-create", - "description": "New address", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/:addressId/edit", - "state": "supplier.card.address.edit", - "component": "vn-supplier-address-edit", - "description": "Edit address" } ] -} \ No newline at end of file +} diff --git a/modules/supplier/front/search-panel/index.html b/modules/supplier/front/search-panel/index.html deleted file mode 100644 index e67fa9083..000000000 --- a/modules/supplier/front/search-panel/index.html +++ /dev/null @@ -1,46 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/supplier/front/search-panel/index.js b/modules/supplier/front/search-panel/index.js deleted file mode 100644 index 6223b5670..000000000 --- a/modules/supplier/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnSupplierSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/supplier/front/search-panel/locale/es.yml b/modules/supplier/front/search-panel/locale/es.yml deleted file mode 100644 index 77253a4ef..000000000 --- a/modules/supplier/front/search-panel/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Province: Provincia -Country: País -Tax number: NIF / CIF -Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias \ No newline at end of file diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html deleted file mode 100644 index 5ba713fcf..000000000 --- a/modules/supplier/front/summary/index.html +++ /dev/null @@ -1,172 +0,0 @@ - -
- - - - {{::$ctrl.summary.name}} - {{::$ctrl.summary.id}} -
- - -

- - Basic data - -

-

- Basic data -

- - - - - - - - {{$ctrl.summary.worker.user.nickname}} - - - - - - - - - -
- -

- - Billing data - -

-

- Billing data -

- - - - - - - - -
-
- - -

- - Fiscal data - -

-

- Fiscal data -

- - - - - - - - - -
-
- - -

- - Fiscal address - -

-

- Fiscal address -

- - - - - - - - - - - - - - -
-
-
- - \ No newline at end of file diff --git a/modules/supplier/front/summary/index.js b/modules/supplier/front/summary/index.js deleted file mode 100644 index a828379bc..000000000 --- a/modules/supplier/front/summary/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; -import './style.scss'; - -class Controller extends Summary { - $onChanges() { - if (!this.supplier) - return; - - this.getSummary(); - } - - get isAdministrative() { - return this.aclService.hasAny(['administrative']); - } - - getSummary() { - return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => { - this.summary = response.data; - }); - } -} - -ngModule.vnComponent('vnSupplierSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/summary/index.spec.js b/modules/supplier/front/summary/index.spec.js deleted file mode 100644 index aa44cd14f..000000000 --- a/modules/supplier/front/summary/index.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import './index'; - -describe('Supplier', () => { - describe('Component vnSupplierSummary', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnSupplierSummary', {$element, $scope}); - })); - - describe('getSummary()', () => { - it('should perform a get asking for the supplier data', () => { - controller.supplier = {id: 1}; - - const query = `Suppliers/${controller.supplier.id}/getSummary`; - - $httpBackend.expectGET(query).respond({id: 1}); - controller.getSummary(); - $httpBackend.flush(); - - expect(controller.summary).toEqual({id: 1}); - }); - }); - }); -}); diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml deleted file mode 100644 index 35291e579..000000000 --- a/modules/supplier/front/summary/locale/es.yml +++ /dev/null @@ -1,12 +0,0 @@ -Verified: Verificado -Country: País -Tax number: NIF / CIF -Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias -Is Farmer: Es agrícola -Sage tax type: Tipo de impuesto Sage -Sage transaction type: Tipo de transacción Sage -Sage withholding: Retencion Sage -Go to the supplier: Ir al proveedor -Responsible: Responsable -Supplier activity: Actividad proveedor -Healt register: Pasaporte sanitario \ No newline at end of file diff --git a/modules/supplier/front/summary/style.scss b/modules/supplier/front/summary/style.scss deleted file mode 100644 index 1eb6b2323..000000000 --- a/modules/supplier/front/summary/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import "variables"; - -vn-client-summary { - .alert span { - color: $color-alert - } -} \ No newline at end of file From d61e32917a525d49ba556cbb8107821b9947a54a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 21 Jun 2024 13:22:59 +0200 Subject: [PATCH 010/137] feat: refs #7562 Created deleteDeprecatedObjects --- db/dump/fixtures.after.sql | 4 +- .../util/events/deleteDeprecatedObjects.sql | 8 ++ .../procedures/deleteDeprecatedObjects.sql | 88 +++++++++++++++++++ .../11113-bronzeDendro/00-firstScript.sql | 22 +++++ 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 db/routines/util/events/deleteDeprecatedObjects.sql create mode 100644 db/routines/util/procedures/deleteDeprecatedObjects.sql create mode 100644 db/versions/11113-bronzeDendro/00-firstScript.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 562ea02d8..a276422e3 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -7,8 +7,8 @@ SET foreign_key_checks = 0; -- XXX: vn-database -INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) - VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); +INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled, daysKeepDeprecatedObjects) + VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE, 60); INSERT INTO util.binlogQueue (code,logName, `position`) VALUES ('mylogger', 'bin.000001', 4); diff --git a/db/routines/util/events/deleteDeprecatedObjects.sql b/db/routines/util/events/deleteDeprecatedObjects.sql new file mode 100644 index 000000000..0d7878a28 --- /dev/null +++ b/db/routines/util/events/deleteDeprecatedObjects.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`deleteDeprecatedObjects` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-06-09 00:01:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL deleteDeprecatedObjects$$ +DELIMITER ; diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql new file mode 100644 index 000000000..a46d806d7 --- /dev/null +++ b/db/routines/util/procedures/deleteDeprecatedObjects.sql @@ -0,0 +1,88 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`deleteDeprecatedObjects`() + MODIFIES SQL DATA +BEGIN +/** + * Elimina objetos deprecados de la base de datos + */ + DECLARE vQuery TEXT; + DECLARE vDated DATE + DEFAULT ( + SELECT CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY + FROM config + ); + DECLARE vDone BOOL; + + DECLARE vObjects CURSOR FOR + SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP PRIMARY KEY;') + FROM information_schema.`COLUMNS` c + LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA + AND v.TABLE_NAME = c.TABLE_NAME + JOIN information_schema.STATISTICS s ON s.TABLE_SCHEMA = c.TABLE_SCHEMA + AND s.TABLE_NAME = c.TABLE_NAME + AND s.COLUMN_NAME = c.COLUMN_NAME + WHERE c.COLUMN_NAME LIKE '%\_\_' + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + AND v.TABLE_NAME IS NULL + AND s.INDEX_NAME = 'PRIMARY' + UNION ALL + SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP FOREIGN KEY ', kcu.CONSTRAINT_NAME, ';') + FROM information_schema.`COLUMNS` c + LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA + AND v.TABLE_NAME = c.TABLE_NAME + JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA + AND kcu.TABLE_NAME = c.TABLE_NAME + AND kcu.COLUMN_NAME = c.COLUMN_NAME + WHERE c.COLUMN_NAME LIKE '%\_\_' + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + AND v.TABLE_NAME IS NULL + AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL + UNION ALL + SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP COLUMN ', c.COLUMN_NAME, ';') + FROM information_schema.`COLUMNS` c + LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA + AND v.TABLE_NAME = c.TABLE_NAME + LEFT JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA + AND kcu.TABLE_NAME = c.TABLE_NAME + AND kcu.COLUMN_NAME = c.COLUMN_NAME + WHERE c.COLUMN_NAME LIKE '%\_\_' + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + AND v.TABLE_NAME IS NULL + UNION ALL + SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') + FROM information_schema.TABLES + WHERE TABLE_NAME LIKE '%\_\_' + AND REGEXP_SUBSTR(TABLE_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Error en la eliminación automática de objetos deprecados', + CONCAT('
', vQuery, '
', + '

Revisa la tabla util.eventLog para más detalles.

') + ); + RESIGNAL; + END; + + IF vDated IS NULL THEN + CALL throw('Variable config not set'); + END IF; + + OPEN vObjects; + l: LOOP + SET vDone = FALSE; + FETCH vObjects INTO vQuery; + + IF vDone THEN + LEAVE l; + END IF; + + CALL `exec`(vQuery); + END LOOP; + CLOSE vObjects; +END$$ +DELIMITER ; diff --git a/db/versions/11113-bronzeDendro/00-firstScript.sql b/db/versions/11113-bronzeDendro/00-firstScript.sql new file mode 100644 index 000000000..b9a324c5e --- /dev/null +++ b/db/versions/11113-bronzeDendro/00-firstScript.sql @@ -0,0 +1,22 @@ +ALTER TABLE util.config + ADD daysKeepDeprecatedObjects int(11) unsigned NULL COMMENT 'Número de días que se mantendrán los objetos deprecados.'; + +UPDATE IGNORE util.config + SET daysKeepDeprecatedObjects = 60; + +ALTER TABLE IF EXISTS `vn`.`payrollWorker` + MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `codpuesto__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `codcontrato__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `FAntiguedad__` date NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `grupotarifa__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `codcategoria__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-03-15 refs #6738'; + +ALTER TABLE IF EXISTS `vn`.`payrollWorkCenter` + MODIFY COLUMN IF EXISTS `Centro__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `domicilio__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `poblacion__` varchar(45) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `cp__` varchar(5) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `empresa_id__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738'; From c330e8c7156a55b9b99c4f7fa1e66aadcf894af0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 21 Jun 2024 13:24:20 +0200 Subject: [PATCH 011/137] feat: refs #7562 Minor change --- db/routines/util/procedures/deleteDeprecatedObjects.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql index a46d806d7..5911e0ab0 100644 --- a/db/routines/util/procedures/deleteDeprecatedObjects.sql +++ b/db/routines/util/procedures/deleteDeprecatedObjects.sql @@ -8,7 +8,7 @@ BEGIN DECLARE vQuery TEXT; DECLARE vDated DATE DEFAULT ( - SELECT CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY + SELECT VN_CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY FROM config ); DECLARE vDone BOOL; From c0668d054f86894f8e3f6ff6a4f7b3e02519266d Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 21 Jun 2024 13:51:33 +0200 Subject: [PATCH 012/137] feat: refs #7562 Changes --- db/dump/fixtures.after.sql | 4 +- .../procedures/deleteDeprecatedObjects.sql | 38 +++++++++++-------- .../11113-bronzeDendro/00-firstScript.sql | 6 ++- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index a276422e3..1353e481b 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -7,8 +7,8 @@ SET foreign_key_checks = 0; -- XXX: vn-database -INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled, daysKeepDeprecatedObjects) - VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE, 60); +INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled, dateRegex, deprecatedMarkRegex, daysKeepDeprecatedObjects) + VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE, '[0-9]{4}-[0-9]{2}-[0-9]{2}', '__$', 60); INSERT INTO util.binlogQueue (code,logName, `position`) VALUES ('mylogger', 'bin.000001', 4); diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql index 5911e0ab0..729f3faf1 100644 --- a/db/routines/util/procedures/deleteDeprecatedObjects.sql +++ b/db/routines/util/procedures/deleteDeprecatedObjects.sql @@ -6,11 +6,9 @@ BEGIN * Elimina objetos deprecados de la base de datos */ DECLARE vQuery TEXT; - DECLARE vDated DATE - DEFAULT ( - SELECT VN_CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY - FROM config - ); + DECLARE vDated DATE; + DECLARE vDateRegex VARCHAR(255); + DECLARE vMarkRegex VARCHAR(255); DECLARE vDone BOOL; DECLARE vObjects CURSOR FOR @@ -21,8 +19,8 @@ BEGIN JOIN information_schema.STATISTICS s ON s.TABLE_SCHEMA = c.TABLE_SCHEMA AND s.TABLE_NAME = c.TABLE_NAME AND s.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME LIKE '%\_\_' - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL AND s.INDEX_NAME = 'PRIMARY' UNION ALL @@ -33,8 +31,8 @@ BEGIN JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA AND kcu.TABLE_NAME = c.TABLE_NAME AND kcu.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME LIKE '%\_\_' - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL UNION ALL @@ -45,20 +43,20 @@ BEGIN LEFT JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA AND kcu.TABLE_NAME = c.TABLE_NAME AND kcu.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME LIKE '%\_\_' - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL UNION ALL SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') FROM information_schema.TABLES - WHERE TABLE_NAME LIKE '%\_\_' - AND REGEXP_SUBSTR(TABLE_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated; + WHERE TABLE_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci + AND REGEXP_SUBSTR(TABLE_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - CALL mail_insert( + CALL vn.mail_insert( 'cau@verdnatura.es', NULL, 'Error en la eliminación automática de objetos deprecados', @@ -68,8 +66,16 @@ BEGIN RESIGNAL; END; - IF vDated IS NULL THEN - CALL throw('Variable config not set'); + SELECT dateRegex, + deprecatedMarkRegex, + VN_CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY + INTO vDateRegex, + vMarkRegex, + vDated + FROM config; + + IF vDateRegex IS NULL OR vMarkRegex IS NULL OR vDated IS NULL THEN + CALL throw('Some config parameters are not set'); END IF; OPEN vObjects; diff --git a/db/versions/11113-bronzeDendro/00-firstScript.sql b/db/versions/11113-bronzeDendro/00-firstScript.sql index b9a324c5e..98ac69966 100644 --- a/db/versions/11113-bronzeDendro/00-firstScript.sql +++ b/db/versions/11113-bronzeDendro/00-firstScript.sql @@ -1,8 +1,12 @@ ALTER TABLE util.config + ADD COLUMN dateRegex varchar(255) NULL COMMENT 'Expresión regular para obtener las fechas.', + ADD deprecatedMarkRegex varchar(255) NULL COMMENT 'Expresión regular para obtener los objetos deprecados.', ADD daysKeepDeprecatedObjects int(11) unsigned NULL COMMENT 'Número de días que se mantendrán los objetos deprecados.'; UPDATE IGNORE util.config - SET daysKeepDeprecatedObjects = 60; + SET dateRegex = '[0-9]{4}-[0-9]{2}-[0-9]{2}', + deprecatedMarkRegex = '__$', + daysKeepDeprecatedObjects = 60; ALTER TABLE IF EXISTS `vn`.`payrollWorker` MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', From aedc8071e1e8175a98c33add6b1c60ff9ffe7a97 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 21 Jun 2024 14:27:22 +0200 Subject: [PATCH 013/137] feat: refs #7562 Changes --- db/routines/util/procedures/deleteDeprecatedObjects.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql index 729f3faf1..a251c3d98 100644 --- a/db/routines/util/procedures/deleteDeprecatedObjects.sql +++ b/db/routines/util/procedures/deleteDeprecatedObjects.sql @@ -23,7 +23,7 @@ BEGIN AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL AND s.INDEX_NAME = 'PRIMARY' - UNION ALL + UNION SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP FOREIGN KEY ', kcu.CONSTRAINT_NAME, ';') FROM information_schema.`COLUMNS` c LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA @@ -35,7 +35,7 @@ BEGIN AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL - UNION ALL + UNION SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP COLUMN ', c.COLUMN_NAME, ';') FROM information_schema.`COLUMNS` c LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA @@ -46,7 +46,7 @@ BEGIN WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL - UNION ALL + UNION SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') FROM information_schema.TABLES WHERE TABLE_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci From 7f278269a5b4e3d48910a9c71c417cc0a52c34cb Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 21 Jun 2024 14:28:55 +0200 Subject: [PATCH 014/137] feat(AccessToken&ACL): refs #7547 upgrade security --- back/methods/vn-token/killSession.js | 29 +++++++++++++++++++ back/model-config.json | 3 ++ back/models/vn-token.js | 5 ++++ back/models/vn-token.json | 22 ++++++++++++++ .../11112-blackRose/00-firstScript.sql | 13 +++++++++ modules/account/front/connections/index.html | 4 +-- modules/account/front/connections/index.js | 4 +-- 7 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 back/methods/vn-token/killSession.js create mode 100644 back/models/vn-token.js create mode 100644 back/models/vn-token.json create mode 100644 db/versions/11112-blackRose/00-firstScript.sql diff --git a/back/methods/vn-token/killSession.js b/back/methods/vn-token/killSession.js new file mode 100644 index 000000000..23d02bfc2 --- /dev/null +++ b/back/methods/vn-token/killSession.js @@ -0,0 +1,29 @@ +module.exports = Self => { + Self.remoteMethodCtx('killSession', { + description: 'Kill session', + accepts: [{ + arg: 'userId', + type: 'integer', + description: 'The user id', + required: true, + }, { + arg: 'created', + type: 'date', + description: 'The created time', + required: true, + }], + accessType: 'WRITE', + http: { + path: `/killSession`, + verb: 'POST' + } + }); + + Self.killSession = async function(ctx, userId, created) { + await Self.app.models.VnUser.userSecurity(ctx, ctx.req.accessToken.userId); + const tokens = await Self.app.models.AccessToken.find({where: {userId, created}}); + if (!tokens?.length) return; + for (const token of tokens) + await Self.app.models.AccessToken.deleteById(token.id); + }; +}; diff --git a/back/model-config.json b/back/model-config.json index b643ab54f..c956e96e5 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -166,6 +166,9 @@ "ViaexpressConfig": { "dataSource": "vn" }, + "VnToken": { + "dataSource": "vn" + }, "VnUser": { "dataSource": "vn" }, diff --git a/back/models/vn-token.js b/back/models/vn-token.js new file mode 100644 index 000000000..03d45dae2 --- /dev/null +++ b/back/models/vn-token.js @@ -0,0 +1,5 @@ +const vnModel = require('vn-loopback/common/models/vn-model'); +module.exports = function(Self) { + vnModel(Self); + require('../methods/vn-token/killSession')(Self); +}; diff --git a/back/models/vn-token.json b/back/models/vn-token.json new file mode 100644 index 000000000..fab8965d6 --- /dev/null +++ b/back/models/vn-token.json @@ -0,0 +1,22 @@ +{ + "name": "VnToken", + "base": "AccessToken", + "options": { + "mysql": { + "table": "salix.AccessToken" + } + }, + "properties": { + "created": { + "type": "date" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userId" + } + }, + "hidden": ["id"] +} diff --git a/db/versions/11112-blackRose/00-firstScript.sql b/db/versions/11112-blackRose/00-firstScript.sql new file mode 100644 index 000000000..c26149240 --- /dev/null +++ b/db/versions/11112-blackRose/00-firstScript.sql @@ -0,0 +1,13 @@ +UPDATE `salix`.`ACL` + SET accessType='READ' + WHERE model = 'ACL'; + +UPDATE `salix`.`ACL` + SET principalId='developerBoss' + WHERE model = 'AccessToken'; + +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('VnToken', '*', 'READ', 'ALLOW', 'ROLE', 'developer'), + ('VnToken', 'killSession', '*', 'ALLOW', 'ROLE', 'developer'), + ('ACL', '*', 'WRITE', 'ALLOW', 'ROLE', 'developerBoss'); diff --git a/modules/account/front/connections/index.html b/modules/account/front/connections/index.html index d634b7a9f..b98fbf5a8 100644 --- a/modules/account/front/connections/index.html +++ b/modules/account/front/connections/index.html @@ -1,6 +1,6 @@ @@ -42,4 +42,4 @@ ng-click="model.refresh()" vn-bind="r" fixed-bottom-right> - \ No newline at end of file + diff --git a/modules/account/front/connections/index.js b/modules/account/front/connections/index.js index c4ddd5615..236174c63 100644 --- a/modules/account/front/connections/index.js +++ b/modules/account/front/connections/index.js @@ -16,8 +16,8 @@ export default class Controller extends Section { }; } - onDisconnect(row) { - return this.$http.delete(`AccessTokens/${row.id}`) + onDisconnect({created, userId}) { + return this.$http.post(`VnTokens/killSession`, {created, userId}) .then(() => this.$.model.refresh()) .then(() => this.vnApp.showSuccess(this.$t('Session killed'))); } From 2064107897592413be6bdabc6e1479ab7dbdaf8f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 4 Jul 2024 15:25:21 +0000 Subject: [PATCH 015/137] feat(salix): #7671 define isDestiny field in model --- back/models/warehouse.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/back/models/warehouse.json b/back/models/warehouse.json index 54006130b..9267900a5 100644 --- a/back/models/warehouse.json +++ b/back/models/warehouse.json @@ -25,6 +25,9 @@ "isManaged": { "type": "boolean" }, + "isDestiny": { + "type": "boolean" + }, "countryFk": { "type": "number" } From ea626821fc410e29ae5aac56ffb416c4613308e6 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 11 Jul 2024 06:17:19 +0200 Subject: [PATCH 016/137] feat(ssalix): refs #7671 #7671 checkDates --- modules/item/back/methods/fixed-price/filter.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index 9c91886c1..5580dfecf 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -137,6 +137,7 @@ module.exports = Self => { SELECT fp.id, fp.itemFk, fp.warehouseFk, + w.name as warehouseName, fp.rate2, fp.rate3, fp.started, @@ -160,6 +161,7 @@ module.exports = Self => { FROM priceFixed fp JOIN item i ON i.id = fp.itemFk JOIN itemType it ON it.id = i.typeFk + JOIN warehouse w ON fp.warehouseFk = w.id `); if (ctx.args.tags) { @@ -183,6 +185,11 @@ module.exports = Self => { } } } + if (ctx.req.query.showBadDates === 'true') { + stmt.merge({ + sql: `WHERE + fp.started< fp.ended `}); + } stmt.merge(conn.makeSuffix(filter)); From 9c5f38648ab84a1e6c5363d4ce8d1aa088124420 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 12 Jul 2024 00:24:26 +0200 Subject: [PATCH 017/137] feat(ssalix): refs #7671 #7671 checkDates to present --- modules/item/back/methods/fixed-price/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index 5580dfecf..0dde9da99 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -188,7 +188,7 @@ module.exports = Self => { if (ctx.req.query.showBadDates === 'true') { stmt.merge({ sql: `WHERE - fp.started< fp.ended `}); + fp.started> util.VN_CURDATE() `}); } stmt.merge(conn.makeSuffix(filter)); From ac0c3b79b4647a51c576cd88b288a03f9975f11e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 15 Jul 2024 15:51:52 +0200 Subject: [PATCH 018/137] feat createLogin refs #6868 --- .../back/methods/account/handle-user.js | 111 ++++++++++++++++++ modules/account/back/models/account.js | 1 + 2 files changed, 112 insertions(+) create mode 100644 modules/account/back/methods/account/handle-user.js diff --git a/modules/account/back/methods/account/handle-user.js b/modules/account/back/methods/account/handle-user.js new file mode 100644 index 000000000..18beb1796 --- /dev/null +++ b/modules/account/back/methods/account/handle-user.js @@ -0,0 +1,111 @@ + +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('handleUser', { + description: 'Manage various aspects related to a user with the app', + accepts: [ + { + arg: 'androidId', + type: 'String', + description: 'Android id' + }, { + arg: 'versionApp', + type: 'String', + description: 'Version app' + }, { + arg: 'nameApp', + type: 'String', + description: 'Version app' + }, + + ], + returns: { + type: 'object', + root: true + }, + http: { + path: `/handleUser`, + verb: 'POST' + } + }); + + Self.loginApp = async(ctx, android_id, versionApp, nameApp, options) => { + const models = Self.app.models; + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + // const login = await models.Account.login(ctx, user, password, myOptions); + + const accessToken = ctx.req.accessToken; + let user = await models.VnUser.findById(accessToken.userId); + console.log(user.id); + + const [[{vIsAuthorized, vMessage}]] = + await Self.rawSql('CALL vn.device_checkLogin(?, ?);', + [user.id, android_id], myOptions); + + if (!vIsAuthorized) + throw new UserError('Not authorized'); + + const isUserInOperator = await models.Operator.findOne({ + where: { + workerFk: user.id + } + }, myOptions); + + if (!isUserInOperator) + await models.Operator.create({'workerFk': user.id}); + + const serialNumber = (await models.DeviceProduction.findOne({ + where: {android_id: android_id} + }, myOptions))?.serialNumber ?? ''; + + await models.DeviceLog.create({ + 'android_id': android_id, + 'userFk': user.id, + 'nameApp': nameApp, + 'versionApp': versionApp, + 'serialNumber': serialNumber + }, myOptions); + // ctx.req.accessToken = {userId}; + const getDataUser = await models.VnUser.getCurrentUserData(ctx); + + const getDataOperator = await models.Operator.findOne({ + where: {workerFk: user.id}, + fields: ['numberOfWagons', 'warehouseFk', 'itemPackingTypeFk', 'sectorFk', 'sector', + 'trainFk', 'train', 'labelerFk', 'printer'], + include: [ + { + relation: 'sector', + scope: { + fields: ['warehouseFk', 'description'], + } + }, { + relation: 'printer', + scope: { + fields: ['name'], + } + }, { + relation: 'train', + scope: { + fields: ['name'], + } + } + + ] + }, myOptions); + + const getVersion = await models.MobileAppVersionControl.getVersion(ctx, nameApp); + + const combinedResult = { + ...getDataOperator.__data, + ...getDataUser.__data, + ...getVersion, + message: vMessage, + serialNumber, + }; + return combinedResult; + }; +}; diff --git a/modules/account/back/models/account.js b/modules/account/back/models/account.js index f89d3079e..4dd1987d5 100644 --- a/modules/account/back/models/account.js +++ b/modules/account/back/models/account.js @@ -11,6 +11,7 @@ module.exports = Self => { require('../methods/account/change-password')(Self); require('../methods/account/set-password')(Self); require('../methods/account/login-app')(Self); + require('../methods/account/handle-user')(Self); Self.setUnverifiedPassword = async(id, pass, options) => { const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options); From ae6963c26d9f0d3a5ef4e15661f942b304d34e79 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Jul 2024 08:19:13 +0200 Subject: [PATCH 019/137] feat handleUser refs #6868 --- modules/account/back/methods/account/handle-user.js | 5 +---- modules/account/back/models/account.js | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/account/back/methods/account/handle-user.js b/modules/account/back/methods/account/handle-user.js index 18beb1796..136ce4800 100644 --- a/modules/account/back/methods/account/handle-user.js +++ b/modules/account/back/methods/account/handle-user.js @@ -30,17 +30,14 @@ module.exports = Self => { } }); - Self.loginApp = async(ctx, android_id, versionApp, nameApp, options) => { + Self.handleUser = async(ctx, android_id, versionApp, nameApp, options) => { const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - // const login = await models.Account.login(ctx, user, password, myOptions); - const accessToken = ctx.req.accessToken; let user = await models.VnUser.findById(accessToken.userId); - console.log(user.id); const [[{vIsAuthorized, vMessage}]] = await Self.rawSql('CALL vn.device_checkLogin(?, ?);', diff --git a/modules/account/back/models/account.js b/modules/account/back/models/account.js index 4dd1987d5..08a5e0811 100644 --- a/modules/account/back/models/account.js +++ b/modules/account/back/models/account.js @@ -10,7 +10,6 @@ module.exports = Self => { require('../methods/account/logout')(Self); require('../methods/account/change-password')(Self); require('../methods/account/set-password')(Self); - require('../methods/account/login-app')(Self); require('../methods/account/handle-user')(Self); Self.setUnverifiedPassword = async(id, pass, options) => { From 144cf20e7148d67d6b3c40da6b6f7ad0615d2e42 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Jul 2024 10:14:19 +0200 Subject: [PATCH 020/137] feat handleUser refs #6868 --- .../account/back/methods/account/login-app.js | 124 ------------------ ...{login-app.spec.js => handle-user.spec.js} | 4 +- 2 files changed, 2 insertions(+), 126 deletions(-) delete mode 100644 modules/account/back/methods/account/login-app.js rename modules/account/back/methods/account/specs/{login-app.spec.js => handle-user.spec.js} (80%) diff --git a/modules/account/back/methods/account/login-app.js b/modules/account/back/methods/account/login-app.js deleted file mode 100644 index 83c727f1a..000000000 --- a/modules/account/back/methods/account/login-app.js +++ /dev/null @@ -1,124 +0,0 @@ - -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethodCtx('loginApp', { - description: 'Login a user with username and password for app', - accepts: [ - { - arg: 'user', - type: 'String', - description: 'The user name', - required: true - }, { - arg: 'password', - type: 'String', - required: true, - description: 'The password' - }, { - arg: 'androidId', - type: 'String', - description: 'Android id' - }, { - arg: 'versionApp', - type: 'String', - description: 'Version app' - }, { - arg: 'nameApp', - type: 'String', - description: 'Version app' - }, - - ], - returns: { - type: 'object', - root: true - }, - http: { - path: `/loginApp`, - verb: 'POST' - } - }); - - Self.loginApp = async(ctx, user, password, android_id, versionApp, nameApp, options) => { - const models = Self.app.models; - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const login = await models.Account.login(ctx, user, password, myOptions); - - const {id: userId} = await models.VnUser.findOne({ - where: { - name: user - } - }); - - const [[{vIsAuthorized, vMessage}]] = - await Self.rawSql('CALL vn.device_checkLogin(?, ?);', - [userId, android_id], myOptions); - - if (!vIsAuthorized) - throw new UserError('Not authorized'); - - const isUserInOperator = await models.Operator.findOne({ - where: { - workerFk: userId - } - }, myOptions); - - if (!isUserInOperator) - await models.Operator.create({'workerFk': userId}); - - const serialNumber = (await models.DeviceProduction.findOne({ - where: {android_id: android_id} - }, myOptions))?.serialNumber ?? ''; - - await models.DeviceLog.create({ - 'android_id': android_id, - 'userFk': userId, - 'nameApp': nameApp, - 'versionApp': versionApp, - 'serialNumber': serialNumber - }, myOptions); - ctx.req.accessToken = {userId}; - const getDataUser = await models.VnUser.getCurrentUserData(ctx); - - const getDataOperator = await models.Operator.findOne({ - where: {workerFk: userId}, - fields: ['numberOfWagons', 'warehouseFk', 'itemPackingTypeFk', 'sectorFk', 'sector', - 'trainFk', 'train', 'labelerFk', 'printer'], - include: [ - { - relation: 'sector', - scope: { - fields: ['warehouseFk', 'description'], - } - }, { - relation: 'printer', - scope: { - fields: ['name'], - } - }, { - relation: 'train', - scope: { - fields: ['name'], - } - } - - ] - }, myOptions); - - const getVersion = await models.MobileAppVersionControl.getVersion(ctx, nameApp); - - const combinedResult = { - ...login, - ...getDataOperator.__data, - ...getDataUser.__data, - ...getVersion, - message: vMessage, - serialNumber, - }; - return combinedResult; - }; -}; diff --git a/modules/account/back/methods/account/specs/login-app.spec.js b/modules/account/back/methods/account/specs/handle-user.spec.js similarity index 80% rename from modules/account/back/methods/account/specs/login-app.spec.js rename to modules/account/back/methods/account/specs/handle-user.spec.js index fc05cd726..621ff28ae 100644 --- a/modules/account/back/methods/account/specs/login-app.spec.js +++ b/modules/account/back/methods/account/specs/handle-user.spec.js @@ -1,9 +1,9 @@ const {models} = require('vn-loopback/server/server'); -describe('Account loginApp()', () => { +describe('Account handleUser()', () => { const ctx = {req: {accessToken: {}}}; fit('should throw an error when user/password is wrong', async() => { - const req = models.Account.loginApp(ctx, 'user', 'pass', 'androidid11234567890', 'warehouse', '10'); + const req = models.Account.handleUser(ctx, 'user', 'pass', 'androidid11234567890', 'warehouse', '10'); await expectAsync(req).toBeRejected(); }); From 7870416860504662b3a332adf90676ac69e257fb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Jul 2024 17:08:38 +0200 Subject: [PATCH 021/137] feat handleUser refs #6868 --- .../back/methods/account/handle-user.js | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/account/back/methods/account/handle-user.js b/modules/account/back/methods/account/handle-user.js index 136ce4800..02b505e39 100644 --- a/modules/account/back/methods/account/handle-user.js +++ b/modules/account/back/methods/account/handle-user.js @@ -9,7 +9,13 @@ module.exports = Self => { arg: 'androidId', type: 'String', description: 'Android id' - }, { + }, + { + arg: 'deviceId', + type: 'String', + description: 'Device id' + }, + { arg: 'versionApp', type: 'String', description: 'Version app' @@ -30,9 +36,10 @@ module.exports = Self => { } }); - Self.handleUser = async(ctx, android_id, versionApp, nameApp, options) => { + Self.handleUser = async(ctx, androidId, deviceId, versionApp, nameApp, options) => { const models = Self.app.models; const myOptions = {}; + if (typeof options == 'object') Object.assign(myOptions, options); @@ -41,7 +48,7 @@ module.exports = Self => { const [[{vIsAuthorized, vMessage}]] = await Self.rawSql('CALL vn.device_checkLogin(?, ?);', - [user.id, android_id], myOptions); + [user.id, androidId], myOptions); if (!vIsAuthorized) throw new UserError('Not authorized'); @@ -55,18 +62,17 @@ module.exports = Self => { if (!isUserInOperator) await models.Operator.create({'workerFk': user.id}); - const serialNumber = (await models.DeviceProduction.findOne({ - where: {android_id: android_id} - }, myOptions))?.serialNumber ?? ''; + const whereCondition = deviceId ? {id: deviceId} : {android_id: androidId}; + const serialNumber = + (await models.DeviceProduction.findOne({where: whereCondition}, myOptions))?.serialNumber ?? ''; await models.DeviceLog.create({ - 'android_id': android_id, + 'android_id': androidId, 'userFk': user.id, 'nameApp': nameApp, 'versionApp': versionApp, 'serialNumber': serialNumber }, myOptions); - // ctx.req.accessToken = {userId}; const getDataUser = await models.VnUser.getCurrentUserData(ctx); const getDataOperator = await models.Operator.findOne({ From a82df8e2a278711b563f87be024d700d5c232149 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Jul 2024 17:20:35 +0200 Subject: [PATCH 022/137] feat handleUser refs #6868 --- .../methods/account/specs/handle-user.spec.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/account/back/methods/account/specs/handle-user.spec.js b/modules/account/back/methods/account/specs/handle-user.spec.js index 621ff28ae..486d9dc7a 100644 --- a/modules/account/back/methods/account/specs/handle-user.spec.js +++ b/modules/account/back/methods/account/specs/handle-user.spec.js @@ -1,21 +1,16 @@ const {models} = require('vn-loopback/server/server'); describe('Account handleUser()', () => { - const ctx = {req: {accessToken: {}}}; - fit('should throw an error when user/password is wrong', async() => { - const req = models.Account.handleUser(ctx, 'user', 'pass', 'androidid11234567890', 'warehouse', '10'); + const ctx = {req: {accessToken: {userId: 9}}}; - await expectAsync(req).toBeRejected(); - }); - - fit('should return data from user', async() => { - const user = 'employee'; - const password = 'nightmare'; + it('should return data from user', async() => { const androidId = 'androidid11234567890'; + const deviceId = 1; const nameApp = 'warehouse'; const versionApp = '10'; - const req = models.Account.loginApp(ctx, user, password, androidId, nameApp, versionApp); - await expectAsync(req).toBeResolved(); + const data = await models.Account.handleUser(ctx, androidId, deviceId, versionApp, nameApp); + + expect(data.numberOfWagons).toBe(2); }); }); From 930e2951b74da376cba76dba7fdab9e326bcd0ff Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 08:27:39 +0200 Subject: [PATCH 023/137] feat: refs #6727 Added started and finished --- db/routines/util/procedures/log_clean.sql | 35 +++++++++++++------ .../11107-pinkAspidistra/00-firstScript.sql | 8 +++-- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index 1401b5dd8..850b26612 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vQueue CURSOR FOR SELECT schemaName, tableName, retentionDays - FROM logClean + FROM logCleanMultiConfig ORDER BY `order`; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -23,18 +23,31 @@ BEGIN SET vDone = FALSE; FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays; - SET vSchemaName = util.quoteIdentifier(vSchemaName); - SET vTableName = util.quoteIdentifier(vTableName); - SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; + IF vRetentionDays THEN - IF vDone THEN - LEAVE l; + UPDATE logCleanMultiConfig + SET `started` = util.VN_NOW() + WHERE schemaName = vSchemaName + AND tableName = vTableName; + + SET vSchemaName = util.quoteIdentifier(vSchemaName); + SET vTableName = util.quoteIdentifier(vTableName); + SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; + + IF vDone THEN + LEAVE l; + END IF; + + CALL util.exec(CONCAT( + 'DELETE FROM ', vSchemaName , '.', vTableName, + " WHERE creationDate < '", vDated, "'" + )); + + UPDATE logCleanMultiConfig + SET `finished` = util.VN_NOW() + WHERE schemaName = vSchemaName + AND tableName = vTableName; END IF; - - CALL util.exec(CONCAT( - 'DELETE FROM ', vSchemaName , '.', vTableName, - " WHERE creationDate < '", vDated, "'" - )); END LOOP; CLOSE vQueue; END$$ diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql index e702da21e..a1c4bb82f 100644 --- a/db/versions/11107-pinkAspidistra/00-firstScript.sql +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -1,12 +1,14 @@ -CREATE OR REPLACE TABLE `util`.`logClean` ( +CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` ( `schemaName` varchar(64) NOT NULL, `tableName` varchar(64) NOT NULL, - `retentionDays` int(11) NOT NULL, + `retentionDays` int(11) DEFAULT NULL, `order` int(11) DEFAULT NULL, + `started` datetime DEFAULT NULL, + `finished` datetime DEFAULT NULL, PRIMARY KEY (`schemaName`,`tableName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO `util`.`logClean` (`schemaName`, `tableName`, `retentionDays`, `order`) +INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`, `retentionDays`, `order`) VALUES ('account', 'roleLog', 'xxx', NULL), ('account', 'userLog', 'xxx', NULL), From 3cf55556120df016e1f6980b2ffebc089b548aae Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 08:58:51 +0200 Subject: [PATCH 024/137] feat: refs #6727 Fixes --- db/routines/util/procedures/log_clean.sql | 24 +++++------ .../11107-pinkAspidistra/00-firstScript.sql | 42 +++++++++---------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index 850b26612..765d5dcbc 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -8,6 +8,7 @@ BEGIN DECLARE vSchemaName VARCHAR(65); DECLARE vTableName VARCHAR(65); DECLARE vRetentionDays INT; + DECLARE vStarted DATETIME; DECLARE vDated DATE; DECLARE vDone BOOL; @@ -23,28 +24,23 @@ BEGIN SET vDone = FALSE; FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays; + IF vDone THEN + LEAVE l; + END IF; + IF vRetentionDays THEN - - UPDATE logCleanMultiConfig - SET `started` = util.VN_NOW() - WHERE schemaName = vSchemaName - AND tableName = vTableName; - - SET vSchemaName = util.quoteIdentifier(vSchemaName); - SET vTableName = util.quoteIdentifier(vTableName); + SET vStarted = util.VN_NOW(); SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; - IF vDone THEN - LEAVE l; - END IF; - CALL util.exec(CONCAT( - 'DELETE FROM ', vSchemaName , '.', vTableName, + 'DELETE FROM ', util.quoteIdentifier(vSchemaName), + '.', util.quoteIdentifier(vTableName), " WHERE creationDate < '", vDated, "'" )); UPDATE logCleanMultiConfig - SET `finished` = util.VN_NOW() + SET `started` = vStarted, + `finished` = VN_NOW() WHERE schemaName = vSchemaName AND tableName = vTableName; END IF; diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql index a1c4bb82f..3ed3df526 100644 --- a/db/versions/11107-pinkAspidistra/00-firstScript.sql +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -8,25 +8,25 @@ CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` ( PRIMARY KEY (`schemaName`,`tableName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`, `retentionDays`, `order`) +INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`) VALUES - ('account', 'roleLog', 'xxx', NULL), - ('account', 'userLog', 'xxx', NULL), - ('vn', 'entryLog', 'xxx', NULL), - ('vn', 'clientLog', 'xxx', NULL), - ('vn', 'itemLog', 'xxx', NULL), - ('vn', 'shelvingLog', 'xxx', NULL), - ('vn', 'workerLog', 'xxx', NULL), - ('vn', 'deviceProductionLog', 'xxx', NULL), - ('vn', 'zoneLog', 'xxx', NULL), - ('vn', 'rateLog', 'xxx', NULL), - ('vn', 'ticketLog', 'xxx', NULL), - ('vn', 'agencyLog', 'xxx', NULL), - ('vn', 'userLog', 'xxx', NULL), - ('vn', 'routeLog', 'xxx', NULL), - ('vn', 'claimLog', 'xxx', NULL), - ('vn', 'supplierLog', 'xxx', NULL), - ('vn', 'invoiceInLog', 'xxx', NULL), - ('vn', 'travelLog', 'xxx', NULL), - ('vn', 'packingSiteDeviceLog', 'xxx', NULL), - ('vn', 'parkingLog', 'xxx', NULL); + ('account', 'roleLog' ), + ('account', 'userLog' ), + ('vn', 'entryLog' ), + ('vn', 'clientLog' ), + ('vn', 'itemLog' ), + ('vn', 'shelvingLog' ), + ('vn', 'workerLog' ), + ('vn', 'deviceProductionLog' ), + ('vn', 'zoneLog' ), + ('vn', 'rateLog' ), + ('vn', 'ticketLog' ), + ('vn', 'agencyLog' ), + ('vn', 'userLog' ), + ('vn', 'routeLog' ), + ('vn', 'claimLog' ), + ('vn', 'supplierLog' ), + ('vn', 'invoiceInLog' ), + ('vn', 'travelLog' ), + ('vn', 'packingSiteDeviceLog' ), + ('vn', 'parkingLog' ); From 11337506298dbd92f92b452ecc0d78e6a6e9bab7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 09:29:15 +0200 Subject: [PATCH 025/137] feat: #6727 Requested changes --- db/routines/util/procedures/log_clean.sql | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index 765d5dcbc..d490165a4 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -6,7 +6,9 @@ BEGIN * dejando únicamente los días de retención configurados. */ DECLARE vSchemaName VARCHAR(65); + DECLARE vSchemaNameQuoted VARCHAR(65); DECLARE vTableName VARCHAR(65); + DECLARE vTableNameQuoted VARCHAR(65); DECLARE vRetentionDays INT; DECLARE vStarted DATETIME; DECLARE vDated DATE; @@ -30,13 +32,15 @@ BEGIN IF vRetentionDays THEN SET vStarted = util.VN_NOW(); + SET vSchemaNameQuoted = util.quoteIdentifier(vSchemaName); + SET vTableNameQuoted = util.quoteIdentifier(vTableName); SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; - CALL util.exec(CONCAT( - 'DELETE FROM ', util.quoteIdentifier(vSchemaName), - '.', util.quoteIdentifier(vTableName), + EXECUTE IMMEDIATE CONCAT( + 'DELETE FROM ', vSchemaNameQuoted, + '.', vTableNameQuoted, " WHERE creationDate < '", vDated, "'" - )); + ); UPDATE logCleanMultiConfig SET `started` = vStarted, From c94ca96226efc19101d07625ec9bf00cb2697125 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 09:29:42 +0200 Subject: [PATCH 026/137] feat: #6727 Minor changes --- db/routines/util/procedures/log_clean.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index d490165a4..aeed9dc44 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -31,9 +31,9 @@ BEGIN END IF; IF vRetentionDays THEN - SET vStarted = util.VN_NOW(); - SET vSchemaNameQuoted = util.quoteIdentifier(vSchemaName); - SET vTableNameQuoted = util.quoteIdentifier(vTableName); + SET vStarted = VN_NOW(); + SET vSchemaNameQuoted = quoteIdentifier(vSchemaName); + SET vTableNameQuoted = quoteIdentifier(vTableName); SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; EXECUTE IMMEDIATE CONCAT( From 9340d474852b40355da18e0a027c52035aee8f5c Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 19 Jul 2024 09:53:41 +0200 Subject: [PATCH 027/137] test: fix connections e2e --- e2e/paths/14-account/04_acl.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/14-account/04_acl.spec.js b/e2e/paths/14-account/04_acl.spec.js index ce2a63b14..180e35e68 100644 --- a/e2e/paths/14-account/04_acl.spec.js +++ b/e2e/paths/14-account/04_acl.spec.js @@ -8,7 +8,7 @@ describe('Account ACL path', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('developer', 'account'); + await page.loginAndModule('developerBoss', 'account'); await page.accessToSection('account.acl'); }); From 2568ac4e923c0e33be1db57d53a6684323ce7188 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 23 Jul 2024 13:24:43 +0200 Subject: [PATCH 028/137] feat: refs #6346 new wagon type section --- db/dump/fixtures.before.sql | 13 ++-- .../11088-bronzeAspidistra/00-firstScript.sql | 26 ++++++++ .../back/methods/wagonType/createWagonType.js | 57 ----------------- .../back/methods/wagonType/deleteWagonType.js | 43 ------------- .../back/methods/wagonType/editWagonType.js | 64 ------------------- .../wagonType/specs/crudWagonType.spec.js | 48 +------------- modules/wagon/back/models/wagon-config.json | 13 ++++ modules/wagon/back/models/wagon-type-tray.js | 16 +++++ .../wagon/back/models/wagon-type-tray.json | 8 +-- modules/wagon/back/models/wagon-type.js | 15 ++++- 10 files changed, 81 insertions(+), 222 deletions(-) create mode 100644 db/versions/11088-bronzeAspidistra/00-firstScript.sql delete mode 100644 modules/wagon/back/methods/wagonType/createWagonType.js delete mode 100644 modules/wagon/back/methods/wagonType/deleteWagonType.js delete mode 100644 modules/wagon/back/methods/wagonType/editWagonType.js create mode 100644 modules/wagon/back/models/wagon-type-tray.js diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 30f1ceb5e..3b799a610 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3024,9 +3024,6 @@ INSERT INTO `vn`.`workerTimeControlMail` (`id`, `workerFk`, `year`, `week`, `sta (3, 9, 2000, 51, 'CONFIRMED', util.VN_NOW(), 1, NULL), (4, 9, 2001, 1, 'SENDED', util.VN_NOW(), 1, NULL); -INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`) - VALUES - (1, 1350, 1900, 200, 50, 6); INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) VALUES @@ -3035,15 +3032,19 @@ INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) (3, 'green', '#00ff00'), (4, 'blue', '#0000ff'); +INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`, `defaultTrayColorFk`) + VALUES + (1, 1350, 1900, 200, 50, 6, 1); + INSERT INTO `vn`.`wagonType` (`id`, `name`, `divisible`) VALUES (1, 'Wagon Type #1', 1); -INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`) +INSERT INTO `vn`.`wagonTypeTray` (`id`, `wagonTypeFk`, `height`, `wagonTypeColorFk`) VALUES - (1, 1, 100, 1), + (1, 1, 0, 1), (2, 1, 50, 2), - (3, 1, 0, 3); + (3, 1, 100, 3); INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`) VALUES diff --git a/db/versions/11088-bronzeAspidistra/00-firstScript.sql b/db/versions/11088-bronzeAspidistra/00-firstScript.sql new file mode 100644 index 000000000..2cc4e715e --- /dev/null +++ b/db/versions/11088-bronzeAspidistra/00-firstScript.sql @@ -0,0 +1,26 @@ +-- Place your SQL code here +DROP TABLE IF EXISTS vn.wagonTypeTray; + +CREATE TABLE vn.wagonTypeTray ( + id INT UNSIGNED auto_increment NULL, + wagonTypeFk int(11) unsigned NULL, + height INT UNSIGNED NULL, + wagonTypeColorFk int(11) unsigned NULL, + CONSTRAINT wagonTypeTray_pk PRIMARY KEY (id), + CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id), + CONSTRAINT wagonTypeTray_wagonTypeColor_FK FOREIGN KEY (wagonTypeColorFk) REFERENCES vn.wagonTypeColor(id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultHeight INT UNSIGNED DEFAULT 0 NULL COMMENT 'Default height in cm for a base tray'; +ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultTrayColorFk int(11) unsigned NULL COMMENT 'Default color for a base tray'; +ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_wagonTypeColor_FK FOREIGN KEY (defaultTrayColorFk) REFERENCES vn.wagonTypeColor(id); + +ALTER TABLE vn.wagonTypeTray DROP FOREIGN KEY wagonTypeTray_wagonType_FK; +ALTER TABLE vn.wagonTypeTray ADD CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT; + + + +-- insertar datos por defecto \ No newline at end of file diff --git a/modules/wagon/back/methods/wagonType/createWagonType.js b/modules/wagon/back/methods/wagonType/createWagonType.js deleted file mode 100644 index fed915b28..000000000 --- a/modules/wagon/back/methods/wagonType/createWagonType.js +++ /dev/null @@ -1,57 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('createWagonType', { - description: 'Creates a new wagon type', - accessType: 'WRITE', - accepts: [ - { - arg: 'name', - type: 'String', - required: true - }, - { - arg: 'divisible', - type: 'boolean', - required: true - }, { - arg: 'trays', - type: 'any', - required: true - } - ], - http: { - path: `/createWagonType`, - verb: 'PATCH' - } - }); - - Self.createWagonType = async(ctx, options) => { - const args = ctx.args; - const models = Self.app.models; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const newWagonType = await models.WagonType.create({name: args.name, divisible: args.divisible}, myOptions); - args.trays.forEach(async tray => { - await models.WagonTypeTray.create({ - typeFk: newWagonType.id, - height: tray.position, - colorFk: tray.color.id - }, myOptions); - }); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/wagon/back/methods/wagonType/deleteWagonType.js b/modules/wagon/back/methods/wagonType/deleteWagonType.js deleted file mode 100644 index 46b65e32f..000000000 --- a/modules/wagon/back/methods/wagonType/deleteWagonType.js +++ /dev/null @@ -1,43 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('deleteWagonType', { - description: 'Deletes a wagon type', - accessType: 'WRITE', - accepts: [ - { - arg: 'id', - type: 'Number', - required: true - } - ], - http: { - path: `/deleteWagonType`, - verb: 'DELETE' - } - }); - - Self.deleteWagonType = async(ctx, options) => { - const args = ctx.args; - const models = Self.app.models; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - await models.Wagon.destroyAll({typeFk: args.id}, myOptions); - await models.WagonTypeTray.destroyAll({typeFk: args.id}, myOptions); - await models.WagonType.destroyAll({id: args.id}, myOptions); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/wagon/back/methods/wagonType/editWagonType.js b/modules/wagon/back/methods/wagonType/editWagonType.js deleted file mode 100644 index bd5ad1f16..000000000 --- a/modules/wagon/back/methods/wagonType/editWagonType.js +++ /dev/null @@ -1,64 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('editWagonType', { - description: 'Edits a new wagon type', - accessType: 'WRITE', - accepts: [ - { - arg: 'id', - type: 'String', - required: true - }, - { - arg: 'name', - type: 'String', - required: true - }, - { - arg: 'divisible', - type: 'boolean', - required: true - }, { - arg: 'trays', - type: 'any', - required: true - } - ], - http: { - path: `/editWagonType`, - verb: 'PATCH' - } - }); - - Self.editWagonType = async(ctx, options) => { - const args = ctx.args; - const models = Self.app.models; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const wagonType = await models.WagonType.findById(args.id, null, myOptions); - wagonType.updateAttributes({name: args.name, divisible: args.divisible}, myOptions); - models.WagonTypeTray.destroyAll({typeFk: args.id}, myOptions); - args.trays.forEach(async tray => { - await models.WagonTypeTray.create({ - typeFk: args.id, - height: tray.position, - colorFk: tray.color.id - }, myOptions); - }); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js b/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js index 92ac61060..96f0980f9 100644 --- a/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js +++ b/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js @@ -1,58 +1,16 @@ const models = require('vn-loopback/server/server').models; describe('WagonType crudWagonType()', () => { - const ctx = { - args: { - name: 'Mock wagon type', - divisible: true, - trays: [{position: 0, color: {id: 1}}, - {position: 50, color: {id: 2}}, - {position: 100, color: {id: 3}}] - } - }; - it(`should create, edit and delete a new wagon type and its trays`, async() => { const tx = await models.WagonType.beginTransaction({}); try { const options = {transaction: tx}; - // create - await models.WagonType.createWagonType(ctx, options); + const wagonType = await models.WagonType.create({name: 'Mock wagon type'}, options); + const newWagonTrays = await models.WagonTypeTray.findOne({where: {typeFk: wagonType.id}}, options); - const newWagonType = await models.WagonType.findOne({where: {name: ctx.args.name}}, options); - const newWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); - - expect(newWagonType).not.toEqual(null); - expect(newWagonType.name).toEqual(ctx.args.name); - expect(newWagonType.divisible).toEqual(ctx.args.divisible); - expect(newWagonTrays.length).toEqual(ctx.args.trays.length); - - ctx.args = { - id: newWagonType.id, - name: 'Edited wagon type', - divisible: false, - trays: [{position: 0, color: {id: 1}}] - }; - - // edit - await models.WagonType.editWagonType(ctx, options); - - const editedWagonType = await models.WagonType.findById(newWagonType.id, null, options); - const editedWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); - - expect(editedWagonType.name).toEqual(ctx.args.name); - expect(editedWagonType.divisible).toEqual(ctx.args.divisible); - expect(editedWagonTrays.length).toEqual(ctx.args.trays.length); - - // delete - await models.WagonType.deleteWagonType(ctx, options); - - const deletedWagonType = await models.WagonType.findById(newWagonType.id, null, options); - const deletedWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); - - expect(deletedWagonType).toEqual(null); - expect(deletedWagonTrays).toEqual([]); + expect(newWagonTrays).toBeDefined(); await tx.rollback(); } catch (e) { diff --git a/modules/wagon/back/models/wagon-config.json b/modules/wagon/back/models/wagon-config.json index 3d96e2864..d76558564 100644 --- a/modules/wagon/back/models/wagon-config.json +++ b/modules/wagon/back/models/wagon-config.json @@ -25,6 +25,19 @@ }, "maxTrays": { "type": "number" + }, + "defaultHeight": { + "type": "number" + }, + "defaultTrayColorFk": { + "type": "number" } + }, + "relations": { + "WagonTypeColor": { + "type": "belongsTo", + "model": "WagonTypeColor", + "foreignKey": "defaultTrayColorFk" + } } } diff --git a/modules/wagon/back/models/wagon-type-tray.js b/modules/wagon/back/models/wagon-type-tray.js new file mode 100644 index 000000000..e32938743 --- /dev/null +++ b/modules/wagon/back/models/wagon-type-tray.js @@ -0,0 +1,16 @@ +// module.exports = Self => { +// Self.observe('before save', async ctx => { +// if (ctx.isNewInstance) { +// const models = Self.app.models; +// const config = await models.WagonConfig.findOne(); + +// await models.WagonTypeTray.create({ +// wagonTypeFk: config.wagonTypeFk, +// height: config.height, +// wagonTypeColorFk: config.wagonTypeColorFk +// }, ctx.options); +// } +// if (ctx.instance < config.minHeightBetweenTrays) +// throw new Error('Height must be greater than ' + config.minHeightBetweenTrays); +// }); +// }; diff --git a/modules/wagon/back/models/wagon-type-tray.json b/modules/wagon/back/models/wagon-type-tray.json index b61510bcf..61b32694d 100644 --- a/modules/wagon/back/models/wagon-type-tray.json +++ b/modules/wagon/back/models/wagon-type-tray.json @@ -11,13 +11,13 @@ "id": true, "type": "number" }, - "typeFk": { + "wagonTypeFk": { "type": "number" }, "height": { "type": "number" }, - "colorFk": { + "wagonTypeColorFk": { "type": "number" } }, @@ -25,12 +25,12 @@ "type": { "type": "belongsTo", "model": "WagonType", - "foreignKey": "typeFk" + "foreignKey": "wagonTypeFk" }, "color": { "type": "belongsTo", "model": "WagonTypeColor", - "foreignKey": "colorFk" + "foreignKey": "wagonTypeColorFk" } } } diff --git a/modules/wagon/back/models/wagon-type.js b/modules/wagon/back/models/wagon-type.js index bebf7a9d9..0610adcb4 100644 --- a/modules/wagon/back/models/wagon-type.js +++ b/modules/wagon/back/models/wagon-type.js @@ -1,5 +1,14 @@ module.exports = Self => { - require('../methods/wagonType/createWagonType')(Self); - require('../methods/wagonType/editWagonType')(Self); - require('../methods/wagonType/deleteWagonType')(Self); + Self.observe('after save', async ctx => { + if (ctx.isNewInstance) { + const models = Self.app.models; + const config = await models.WagonConfig.findOne(); + + await models.WagonTypeTray.create({ + wagonTypeFk: ctx.instance.id, + height: config.defaultHeight, + wagonTypeColorFk: config.defaultTrayColorFk + }, ctx.options); + } + }); }; From 57f6c6d9a1b4f5214c3bb1b3d5f612f335d137e2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 31 Jul 2024 10:43:55 +0200 Subject: [PATCH 029/137] chore: refs #7663 WIP setWeight --- .../11178-yellowCamellia/00-aclSetWeight.sql | 9 +++ loopback/locale/es.json | 3 +- .../ticket/back/methods/ticket/setWeight.js | 75 +++++++++++++++++++ modules/ticket/back/models/ticket-methods.js | 1 + modules/ticket/front/summary/locale/es.yml | 3 +- 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 db/versions/11178-yellowCamellia/00-aclSetWeight.sql create mode 100644 modules/ticket/back/methods/ticket/setWeight.js diff --git a/db/versions/11178-yellowCamellia/00-aclSetWeight.sql b/db/versions/11178-yellowCamellia/00-aclSetWeight.sql new file mode 100644 index 000000000..d70287738 --- /dev/null +++ b/db/versions/11178-yellowCamellia/00-aclSetWeight.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +INSERT INTO salix.ACL + SET model = 'Ticket', + property = 'setWeight', + accessType = 'WRITE', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'salesPerson'; + \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index acc3d69f6..eb7a2aaf2 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -368,5 +368,6 @@ "Payment method is required": "El método de pago es obligatorio", "Cannot send mail": "Não é possível enviar o email", "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", - "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo" + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", + "Weight already set": "El peso ya está establecido" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js new file mode 100644 index 000000000..f2a65b1d6 --- /dev/null +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -0,0 +1,75 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('setWeight', { + description: 'Sets weight of a ticket', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The ticket id', + http: {source: 'path'} + }, { + arg: 'weight', + type: 'number', + required: true, + description: 'The weight value', + }], + http: { + path: `/:id/setWeight`, + verb: 'POST' + } + }); + + Self.setWeight = async(ctx, ticketId, weight, invoiceable, options) => { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; + let tx; + + if (typeof options == 'object') Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + if (ticket.weight) throw new UserError('Weight already set'); + + const canEdit = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'updateAttributes'); + const ticket = await Self.findById(ticketId, null, myOptions); + const client = await models.Client.findById(ticket.clientFk, { + include: {relation: 'salesPersonUser'}}, + myOptions); + + if (!canEdit) { + const salesPersonUser = client.salesPersonUser(); + const workerDepartments = await models.WorkerDepartment.find({ + include: {relation: 'department'}, + where: {workerFk: {inq: [userId, salesPersonUser.id]}} + }, myOptions); + + if (workerDepartments[0].departmentFk != workerDepartments[1].departmentFk) + throw new UserError('You don\'t have enough privileges'); + } + + await ticket.updateAttribute('weight', weight, myOptions); + + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, myOptions); + const ticketState = await models.TicketState.findOne({where: {ticketFk: ticketId}}, myOptions); + + const [{taxArea}] = await Self.rawSql('SELECT clientTaxArea(?,?) taxArea', + [ticket.clientFk, ticket.warehouseFk], myOptions); + + if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) + await Self.invoiceTicketsAndPdf(ctx, [ticketId], null, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 5582dde5c..457454627 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -47,4 +47,5 @@ module.exports = function(Self) { require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/myLastModified')(Self); require('../methods/ticket/clone')(Self); + require('../methods/ticket/setWeight')(Self); }; diff --git a/modules/ticket/front/summary/locale/es.yml b/modules/ticket/front/summary/locale/es.yml index d1e6dba58..9de7ccbf4 100644 --- a/modules/ticket/front/summary/locale/es.yml +++ b/modules/ticket/front/summary/locale/es.yml @@ -3,4 +3,5 @@ Address mobile: Móv. consignatario Client phone: Tel. cliente Client mobile: Móv. cliente Go to the ticket: Ir al ticket -Change state: Cambiar estado \ No newline at end of file +Change state: Cambiar estado +Weight: Peso \ No newline at end of file From 52d62710e6347cc2b8e8d6ab8fb49effaf663757 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Aug 2024 13:49:00 +0200 Subject: [PATCH 030/137] chore: refs #7663 fix logic --- .../ticket/back/methods/ticket/setWeight.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index f2a65b1d6..4f9e1883e 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -16,13 +16,17 @@ module.exports = Self => { required: true, description: 'The weight value', }], + returns: { + type: 'boolean', + root: true + }, http: { path: `/:id/setWeight`, verb: 'POST' } }); - Self.setWeight = async(ctx, ticketId, weight, invoiceable, options) => { + Self.setWeight = async(ctx, ticketId, weight, options) => { const models = Self.app.models; const userId = ctx.req.accessToken.userId; const myOptions = {userId}; @@ -36,10 +40,10 @@ module.exports = Self => { } try { + const ticket = await Self.findById(ticketId, null, myOptions); if (ticket.weight) throw new UserError('Weight already set'); const canEdit = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'updateAttributes'); - const ticket = await Self.findById(ticketId, null, myOptions); const client = await models.Client.findById(ticket.clientFk, { include: {relation: 'salesPersonUser'}}, myOptions); @@ -51,7 +55,10 @@ module.exports = Self => { where: {workerFk: {inq: [userId, salesPersonUser.id]}} }, myOptions); - if (workerDepartments[0].departmentFk != workerDepartments[1].departmentFk) + if ( + workerDepartments.length == 2 && + workerDepartments[0].departmentFk != workerDepartments[1].departmentFk + ) throw new UserError('You don\'t have enough privileges'); } @@ -63,10 +70,12 @@ module.exports = Self => { const [{taxArea}] = await Self.rawSql('SELECT clientTaxArea(?,?) taxArea', [ticket.clientFk, ticket.warehouseFk], myOptions); - if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) + if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) { await Self.invoiceTicketsAndPdf(ctx, [ticketId], null, myOptions); - + return true; + } if (tx) await tx.commit(); + return false; } catch (e) { if (tx) await tx.rollback(); throw e; From 6c9676ce9c90f145b638d3ec293e6d44d274d2db Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Aug 2024 14:52:26 +0200 Subject: [PATCH 031/137] chore: refs #7663 fix logic --- modules/ticket/back/methods/ticket/setWeight.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index 4f9e1883e..91ecef634 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -70,12 +70,13 @@ module.exports = Self => { const [{taxArea}] = await Self.rawSql('SELECT clientTaxArea(?,?) taxArea', [ticket.clientFk, ticket.warehouseFk], myOptions); - if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) { - await Self.invoiceTicketsAndPdf(ctx, [ticketId], null, myOptions); - return true; - } + const isInvoiceable = ticketState.alertLevel >= packedState.alertLevel && + taxArea == 'WORLD' && client.hasDailyInvoice; + if (tx) await tx.commit(); - return false; + if (isInvoiceable) await Self.invoiceTicketsAndPdf(ctx, [ticketId]); + + return isInvoiceable; } catch (e) { if (tx) await tx.rollback(); throw e; From 2ba391fc85bacc338914002bdab00c449339e188 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Sep 2024 07:57:00 +0200 Subject: [PATCH 032/137] feat: refs #7562 Deleted deleteDeprecatedObjects objects --- .../util/events/deleteDeprecatedObjects.sql | 8 -- .../procedures/deleteDeprecatedObjects.sql | 94 ------------------- 2 files changed, 102 deletions(-) delete mode 100644 db/routines/util/events/deleteDeprecatedObjects.sql delete mode 100644 db/routines/util/procedures/deleteDeprecatedObjects.sql diff --git a/db/routines/util/events/deleteDeprecatedObjects.sql b/db/routines/util/events/deleteDeprecatedObjects.sql deleted file mode 100644 index 0d7878a28..000000000 --- a/db/routines/util/events/deleteDeprecatedObjects.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`deleteDeprecatedObjects` - ON SCHEDULE EVERY 1 DAY - STARTS '2024-06-09 00:01:00.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL deleteDeprecatedObjects$$ -DELIMITER ; diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql deleted file mode 100644 index a251c3d98..000000000 --- a/db/routines/util/procedures/deleteDeprecatedObjects.sql +++ /dev/null @@ -1,94 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`deleteDeprecatedObjects`() - MODIFIES SQL DATA -BEGIN -/** - * Elimina objetos deprecados de la base de datos - */ - DECLARE vQuery TEXT; - DECLARE vDated DATE; - DECLARE vDateRegex VARCHAR(255); - DECLARE vMarkRegex VARCHAR(255); - DECLARE vDone BOOL; - - DECLARE vObjects CURSOR FOR - SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP PRIMARY KEY;') - FROM information_schema.`COLUMNS` c - LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA - AND v.TABLE_NAME = c.TABLE_NAME - JOIN information_schema.STATISTICS s ON s.TABLE_SCHEMA = c.TABLE_SCHEMA - AND s.TABLE_NAME = c.TABLE_NAME - AND s.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated - AND v.TABLE_NAME IS NULL - AND s.INDEX_NAME = 'PRIMARY' - UNION - SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP FOREIGN KEY ', kcu.CONSTRAINT_NAME, ';') - FROM information_schema.`COLUMNS` c - LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA - AND v.TABLE_NAME = c.TABLE_NAME - JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA - AND kcu.TABLE_NAME = c.TABLE_NAME - AND kcu.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated - AND v.TABLE_NAME IS NULL - AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL - UNION - SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP COLUMN ', c.COLUMN_NAME, ';') - FROM information_schema.`COLUMNS` c - LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA - AND v.TABLE_NAME = c.TABLE_NAME - LEFT JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA - AND kcu.TABLE_NAME = c.TABLE_NAME - AND kcu.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated - AND v.TABLE_NAME IS NULL - UNION - SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') - FROM information_schema.TABLES - WHERE TABLE_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci - AND REGEXP_SUBSTR(TABLE_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - CALL vn.mail_insert( - 'cau@verdnatura.es', - NULL, - 'Error en la eliminación automática de objetos deprecados', - CONCAT('
', vQuery, '
', - '

Revisa la tabla util.eventLog para más detalles.

') - ); - RESIGNAL; - END; - - SELECT dateRegex, - deprecatedMarkRegex, - VN_CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY - INTO vDateRegex, - vMarkRegex, - vDated - FROM config; - - IF vDateRegex IS NULL OR vMarkRegex IS NULL OR vDated IS NULL THEN - CALL throw('Some config parameters are not set'); - END IF; - - OPEN vObjects; - l: LOOP - SET vDone = FALSE; - FETCH vObjects INTO vQuery; - - IF vDone THEN - LEAVE l; - END IF; - - CALL `exec`(vQuery); - END LOOP; - CLOSE vObjects; -END$$ -DELIMITER ; From 4c5f5c8324c8424d3bbb001fae7c7c4538694ca3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Sep 2024 17:08:23 +0200 Subject: [PATCH 033/137] fix: refs #7663 conflicts --- modules/ticket/back/models/ticket-methods.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index cb2baf01f..12161d5f5 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -46,6 +46,5 @@ module.exports = function(Self) { require('../methods/ticket/invoiceTicketsAndPdf')(Self); require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/myLastModified')(Self); - require('../methods/ticket/clone')(Self); require('../methods/ticket/setWeight')(Self); }; From 29b0851741b20d5641d283cebd3125bebd50017c Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 3 Sep 2024 14:35:05 +0200 Subject: [PATCH 034/137] refactor: refs #6346 hook added in wagon-type-tray model --- .../11088-bronzeAspidistra/00-firstScript.sql | 5 --- loopback/locale/es.json | 8 +++- modules/wagon/back/models/wagon-type-tray.js | 42 ++++++++++++------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/db/versions/11088-bronzeAspidistra/00-firstScript.sql b/db/versions/11088-bronzeAspidistra/00-firstScript.sql index 2cc4e715e..98203c9d1 100644 --- a/db/versions/11088-bronzeAspidistra/00-firstScript.sql +++ b/db/versions/11088-bronzeAspidistra/00-firstScript.sql @@ -1,4 +1,3 @@ --- Place your SQL code here DROP TABLE IF EXISTS vn.wagonTypeTray; CREATE TABLE vn.wagonTypeTray ( @@ -20,7 +19,3 @@ ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_wagonTypeColor_FK FOREIGN ALTER TABLE vn.wagonTypeTray DROP FOREIGN KEY wagonTypeTray_wagonType_FK; ALTER TABLE vn.wagonTypeTray ADD CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT; - - - --- insertar datos por defecto \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e2be5d013..47601ae41 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -367,5 +367,9 @@ "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", "Payment method is required": "El método de pago es obligatorio", "Cannot send mail": "Não é possível enviar o email", - "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos" -} + "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", + "There is already a tray with the same height": "Ya existe una bandeja con la misma altura", + "You must define wagon and height": "Debes definir un tipo de vagón y la altura", + "The maximum height of the wagon is": "La altura máxima es %d", + "The height must be greater than": "The height must be greater than %d" +} \ No newline at end of file diff --git a/modules/wagon/back/models/wagon-type-tray.js b/modules/wagon/back/models/wagon-type-tray.js index e32938743..5bcb1d3c7 100644 --- a/modules/wagon/back/models/wagon-type-tray.js +++ b/modules/wagon/back/models/wagon-type-tray.js @@ -1,16 +1,28 @@ -// module.exports = Self => { -// Self.observe('before save', async ctx => { -// if (ctx.isNewInstance) { -// const models = Self.app.models; -// const config = await models.WagonConfig.findOne(); +const UserError = require('vn-loopback/util/user-error'); -// await models.WagonTypeTray.create({ -// wagonTypeFk: config.wagonTypeFk, -// height: config.height, -// wagonTypeColorFk: config.wagonTypeColorFk -// }, ctx.options); -// } -// if (ctx.instance < config.minHeightBetweenTrays) -// throw new Error('Height must be greater than ' + config.minHeightBetweenTrays); -// }); -// }; +module.exports = Self => { + Self.observe('before save', async ctx => { + if (ctx.isNewInstance) { + const models = Self.app.models; + const {wagonTypeFk, height} = ctx.instance; + const trays = await models.WagonTypeTray.find({where: {wagonTypeFk}}); + + const config = await models.WagonConfig.findOne(); + const tray = await models.WagonTypeTray.find({where: {wagonTypeFk, height}}); + + if (!trays.length) return; + + if (tray.length) + throw new UserError('There is already a tray with the same height'); + + if (!wagonTypeFk && !height) + throw new UserError('You must define wagon and height'); + + if (height < config.minHeightBetweenTrays) + throw new UserError('The height must be greater than', 'HEIGHT_GREATER_THAN', config.minHeightBetweenTrays); + + if (height > config.maxWagonHeight) + throw new UserError('The maximum height of the wagon is', 'MAX_WAGON_HEIGHT', config.maxWagonHeight); + } + }); +}; From 77fd3e7f460b96eb19f4fdb1e1008dfa24720728 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 3 Sep 2024 14:42:07 +0200 Subject: [PATCH 035/137] feat: refs #7898 Add column "floor" in vn.parking --- db/versions/11211-greenCataractarum/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11211-greenCataractarum/00-firstScript.sql diff --git a/db/versions/11211-greenCataractarum/00-firstScript.sql b/db/versions/11211-greenCataractarum/00-firstScript.sql new file mode 100644 index 000000000..55b73925c --- /dev/null +++ b/db/versions/11211-greenCataractarum/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.parking ADD COLUMN floor VARCHAR(5) DEFAULT '--' AFTER row; From 36cf6b1aeee927320e58e19917405d88d26f533a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 3 Sep 2024 16:50:55 +0200 Subject: [PATCH 036/137] feat: refs #6868 refs# 6868 handleUser --- modules/account/back/models/account.js | 1 - .../account => worker/back/methods/device}/handle-user.js | 0 .../back/methods/device}/specs/handle-user.spec.js | 4 ++-- modules/worker/back/models/device.js | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) rename modules/{account/back/methods/account => worker/back/methods/device}/handle-user.js (100%) rename modules/{account/back/methods/account => worker/back/methods/device}/specs/handle-user.spec.js (72%) diff --git a/modules/account/back/models/account.js b/modules/account/back/models/account.js index 08a5e0811..ceb26053c 100644 --- a/modules/account/back/models/account.js +++ b/modules/account/back/models/account.js @@ -10,7 +10,6 @@ module.exports = Self => { require('../methods/account/logout')(Self); require('../methods/account/change-password')(Self); require('../methods/account/set-password')(Self); - require('../methods/account/handle-user')(Self); Self.setUnverifiedPassword = async(id, pass, options) => { const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options); diff --git a/modules/account/back/methods/account/handle-user.js b/modules/worker/back/methods/device/handle-user.js similarity index 100% rename from modules/account/back/methods/account/handle-user.js rename to modules/worker/back/methods/device/handle-user.js diff --git a/modules/account/back/methods/account/specs/handle-user.spec.js b/modules/worker/back/methods/device/specs/handle-user.spec.js similarity index 72% rename from modules/account/back/methods/account/specs/handle-user.spec.js rename to modules/worker/back/methods/device/specs/handle-user.spec.js index 486d9dc7a..c4cd37e33 100644 --- a/modules/account/back/methods/account/specs/handle-user.spec.js +++ b/modules/worker/back/methods/device/specs/handle-user.spec.js @@ -1,6 +1,6 @@ const {models} = require('vn-loopback/server/server'); -describe('Account handleUser()', () => { +describe('Device handleUser()', () => { const ctx = {req: {accessToken: {userId: 9}}}; it('should return data from user', async() => { @@ -9,7 +9,7 @@ describe('Account handleUser()', () => { const nameApp = 'warehouse'; const versionApp = '10'; - const data = await models.Account.handleUser(ctx, androidId, deviceId, versionApp, nameApp); + const data = await models.Device.handleUser(ctx, androidId, deviceId, versionApp, nameApp); expect(data.numberOfWagons).toBe(2); }); diff --git a/modules/worker/back/models/device.js b/modules/worker/back/models/device.js index cda7a958f..6a7d5dba5 100644 --- a/modules/worker/back/models/device.js +++ b/modules/worker/back/models/device.js @@ -1,6 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { + require('../methods/device/handle-user')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(``); From 9797d5e219b1c3d1a1a9a57f50163f1b7ded9087 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 3 Sep 2024 17:33:44 +0200 Subject: [PATCH 037/137] feat: refs #7663 return created invoice ids --- modules/ticket/back/methods/ticket/setWeight.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index 91ecef634..d71f2c0e5 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -74,9 +74,10 @@ module.exports = Self => { taxArea == 'WORLD' && client.hasDailyInvoice; if (tx) await tx.commit(); - if (isInvoiceable) await Self.invoiceTicketsAndPdf(ctx, [ticketId]); + let invoiceIds = []; + if (isInvoiceable) invoiceIds = [...await Self.invoiceTicketsAndPdf(ctx, [ticketId])]; - return isInvoiceable; + return invoiceIds; } catch (e) { if (tx) await tx.rollback(); throw e; From df5961a2a2bb196ca9e794c15fd73d80f5ce2973 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 4 Sep 2024 11:41:47 +0200 Subject: [PATCH 038/137] feat: refs #7663 wip test --- .../methods/ticket/specs/setWeight.spec.js | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 modules/ticket/back/methods/ticket/specs/setWeight.spec.js diff --git a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js new file mode 100644 index 000000000..0d48d4adf --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js @@ -0,0 +1,82 @@ +const {models} = require('vn-loopback/server/server'); + +fdescribe('ticket setWeight()', () => { + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); + let opts; + let tx; + const administrativeId = 5; + + beforeEach(async() => { + opts = {transaction: tx}; + tx = await models.Ticket.beginTransaction({}); + opts.transaction = tx; + }); + + afterEach(async() => await tx.rollback()); + + xit('should throw an error if the weight is already set', async() => { + try { + const ticketId = 1; + const weight = 10; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + } catch (e) { + expect(e.message).toEqual('Weight already set'); + } + }); + + xit('should set the weight of a ticket', async() => { + const ticketId = 31; + const weight = 15; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + + const ticket = await models.Ticket.findById(ticketId, null, opts); + + expect(ticket.weight).toEqual(weight); + }); + + it('should throw an error if the user does not have enough privileges', async() => { + ctx.req.accessToken.userId = administrativeId; + try { + const ticketId = 10; + const weight = 20; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + } catch (e) { + expect(e.message).toEqual('You don\'t have enough privilegs'); + } + }); + + // it('should commit the transaction and return invoice ids if the ticket is invoiceable', async() => { + // const tx = await models.Ticket.beginTransaction({}); + + // try { + // const opts = {transaction: tx}; + + // const ticketId = 4; + // const weight = 25; + + // // Mock the necessary methods and data + // jest.spyOn(models.ACL, 'checkAccessAcl').mockResolvedValue(true); + // jest.spyOn(models.Client, 'findById').mockResolvedValue({ + // hasDailyInvoice: true, + // salesPersonUser: () => ({id: 1}) + // }); + // jest.spyOn(models.State, 'findOne').mockResolvedValue({alertLevel: 2}); + // jest.spyOn(models.TicketState, 'findOne').mockResolvedValue({alertLevel: 3}); + // jest.spyOn(models.Ticket, 'rawSql').mockResolvedValue([{taxArea: 'WORLD'}]); + // jest.spyOn(models.Ticket, 'invoiceTicketsAndPdf').mockResolvedValue([1001]); + + // const invoiceIds = await models.Ticket.setWeight(ctx, ticketId, weight, opts); + + // expect(invoiceIds).toEqual([1001]); + + // await tx.rollback(); + // } catch (e) { + // await tx.rollback(); + // throw e; + // } + // }); +}); From 75be124e1f9e600d74b509cb3d22e7f417c79681 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 4 Sep 2024 14:14:12 +0200 Subject: [PATCH 039/137] feat: refs #7929 create table material --- .../11213-aquaCarnation/00-firstScript.sql | 253 ++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 db/versions/11213-aquaCarnation/00-firstScript.sql diff --git a/db/versions/11213-aquaCarnation/00-firstScript.sql b/db/versions/11213-aquaCarnation/00-firstScript.sql new file mode 100644 index 000000000..3067ce06e --- /dev/null +++ b/db/versions/11213-aquaCarnation/00-firstScript.sql @@ -0,0 +1,253 @@ + +use vn; + +CREATE TABLE IF NOT EXISTS `material` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `material` (`name`) VALUES ('Abedul'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acacia'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acero'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acero Galvanizado'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acetato'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acrílico'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Alambre'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Algodón'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Aluminio'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Antracita'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Arcilla'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Bambú'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Banano'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Canneté'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cartón'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cartulina'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Celofán'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cemento'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cera'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cerámica'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Chapa'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Chenilla'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cloruro de polivinilo'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cobre'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Corcho'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cordel'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton Chess'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cristal'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cubo Asa'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cuerda'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cuero'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Raso'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Velvet'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Eco Glass'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Encaje'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Esparto'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Espuma'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Felpa'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Coco'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Vidrio y Resina'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Fieltro'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Foam'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Gamuza'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Gasa'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Glass'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Goma'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Grafito'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Hierro'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja Carbono'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja de Mirto'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Hormigón'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Jute'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Kraft'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Lana'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Látex'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Latrix'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Lienzo'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Lino'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Lurex'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Madera'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Metacrilato'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Metal'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Mimbre'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Musgo'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Nonwoven'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Nylon'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Organza'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Paja'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Pana'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Papel'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Paperweb'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Paulownia'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Peluche'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Piedra'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Pizarra'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Poliestireno'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Polipropileno'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Poliresina'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Polyester'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Porcelana'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Puntilla'); +INSERT IGNORE INTO `material` (`name`) VALUES ('PVC'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rafia'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rama'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Raso'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rattan'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rayon'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Reciclable'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Red'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Resina'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Roca'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rope'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Saco'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Salim'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Seagrass'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Silicona'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Sisal'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Tejido'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Tela'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Terciopelo'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Terracota'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Textil'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Titanio'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Tul'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Velvet'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Vidrio'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Yute'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Zinc'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Base de goma'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Base de madera'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Plumas'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Protección Uva'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Purpurina'); + +CREATE TABLE IF NOT EXISTS `secondaryMaterial` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Abedul'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acacia'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acero'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acero Galvanizado'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acetato'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acrílico'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Alambre'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Algodón'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Aluminio'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Antracita'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Arcilla'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Bambú'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Banano'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Canneté'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cartón'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cartulina'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Celofán'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cemento'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cera'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cerámica'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Chapa'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Chenilla'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cloruro de polivinilo'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cobre'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Corcho'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cordel'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cotton'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cotton Chess'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cristal'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cubo Asa'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cuerda'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cuero'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Doble Raso'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Doble Velvet'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Eco Glass'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Encaje'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Esparto'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Espuma'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Felpa'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Fibra'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Fibra de Coco'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Fibra de Vidrio y Resina'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Fieltro'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Foam'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Gamuza'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Gasa'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Glass'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Goma'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Grafito'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Hierro'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Hoja Carbono'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Hoja de Mirto'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Hormigón'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Jute'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Kraft'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Lana'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Látex'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Latrix'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Lienzo'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Lino'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Lurex'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Madera'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Metacrilato'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Metal'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Mimbre'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Musgo'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Nonwoven'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Nylon'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Organza'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Paja'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Pana'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Papel'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Paperweb'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Paulownia'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Peluche'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Piedra'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Pizarra'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Poliestireno'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Polipropileno'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Poliresina'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Polyester'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Porcelana'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Puntilla'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('PVC'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rafia'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rama'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Raso'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rattan'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rayon'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Reciclable'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Red'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Resina'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Roca'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rope'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Saco'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Salim'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Seagrass'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Silicona'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Sisal'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Tejido'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Tela'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Terciopelo'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Terracota'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Textil'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Titanio'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Tul'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Velvet'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Vidrio'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Yute'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Zinc'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Base de goma'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Base de madera'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Plumas'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Protección Uva'); +INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Purpurina'); + +UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name= 'Material'; +UPDATE vn.tag SET isFree=0,sourceTable='secondaryMaterial' WHERE name='Material secundario'; \ No newline at end of file From e3015a655917c69cfcfff66c11356db7141fe1bd Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 4 Sep 2024 14:52:53 +0200 Subject: [PATCH 040/137] feat: refs #7524 no apply limit --- loopback/common/models/vn-model.js | 10 +++++++--- modules/item/back/methods/item/getBalance.js | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index a11bed11d..269ed673d 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,19 +28,19 @@ module.exports = function(Self) { }); this.beforeRemote('**', async ctx => { - if (!this.hasFilter(ctx)) return; + if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; const defaultLimit = this.app.orm.selectLimit; const filter = ctx.args.filter || {limit: defaultLimit}; - if (filter.limit > defaultLimit) { + if (!filter.limit || filter.limit > defaultLimit) { filter.limit = defaultLimit; ctx.args.filter = filter; } }); this.afterRemote('**', async ctx => { - if (!this.hasFilter(ctx)) return; + if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; @@ -351,6 +351,10 @@ module.exports = function(Self) { hasFilter(ctx) { return ctx.req.method.toUpperCase() === 'GET' && ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); + }, + + hasNoLimit(ctx) { + return ctx.method.accepts.some(x => x.arg.toLowerCase() === 'nolimit') && ctx.args.noLimit; } }); diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 207f8020f..1a4c7999d 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -8,6 +8,10 @@ module.exports = Self => { required: true, description: 'Filter defining where and paginated data', http: {source: 'query'} + }, { + arg: 'noLimit', + type: 'Boolean', + required: false, }], returns: { type: ['Object'], @@ -19,7 +23,7 @@ module.exports = Self => { } }); - Self.getBalance = async(ctx, filter, options) => { + Self.getBalance = async(ctx, filter, noLimit, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') From d82f9b2cd6e2f946ff37621e4226e4bdf91ac35b Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 4 Sep 2024 14:55:59 +0200 Subject: [PATCH 041/137] chore: refs #7524 fix test --- modules/item/back/methods/item/specs/getBalance.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index 95de3cc50..cef206411 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -23,7 +23,7 @@ describe('item getBalance()', () => { date: null } }; - const results = await models.Item.getBalance(ctx, filter, options); + const results = await models.Item.getBalance(ctx, filter, true, options); const result = results.find(element => element.clientType == 'loses'); @@ -57,8 +57,8 @@ describe('item getBalance()', () => { } }; - const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, options); - const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options); + const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, true, options); + const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, true, options); expect(firstItemBalance[9].claimFk).toEqual(null); expect(secondItemBalance[7].claimFk).toEqual(1); From 998d3865a357be22c63c3c9759c65fc45133048e Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 5 Sep 2024 08:56:15 +0200 Subject: [PATCH 042/137] chore: refs #7663 fix test --- .../methods/ticket/specs/setWeight.spec.js | 52 +++++++------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js index 0d48d4adf..c26ae7aaf 100644 --- a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js @@ -1,21 +1,23 @@ const {models} = require('vn-loopback/server/server'); -fdescribe('ticket setWeight()', () => { +describe('ticket setWeight()', () => { const ctx = beforeAll.getCtx(); beforeAll.mockLoopBackContext(); let opts; let tx; + const employeeId = 1; const administrativeId = 5; beforeEach(async() => { opts = {transaction: tx}; tx = await models.Ticket.beginTransaction({}); opts.transaction = tx; + ctx.req.accessToken.userId = administrativeId; }); afterEach(async() => await tx.rollback()); - xit('should throw an error if the weight is already set', async() => { + it('should throw an error if the weight is already set', async() => { try { const ticketId = 1; const weight = 10; @@ -26,7 +28,7 @@ fdescribe('ticket setWeight()', () => { } }); - xit('should set the weight of a ticket', async() => { + it('should set the weight of a ticket', async() => { const ticketId = 31; const weight = 15; @@ -38,45 +40,31 @@ fdescribe('ticket setWeight()', () => { }); it('should throw an error if the user does not have enough privileges', async() => { - ctx.req.accessToken.userId = administrativeId; + ctx.req.accessToken.userId = employeeId; try { const ticketId = 10; const weight = 20; await models.Ticket.setWeight(ctx, ticketId, weight, opts); } catch (e) { - expect(e.message).toEqual('You don\'t have enough privilegs'); + expect(e.message).toEqual('You don\'t have enough privileges'); } }); - // it('should commit the transaction and return invoice ids if the ticket is invoiceable', async() => { - // const tx = await models.Ticket.beginTransaction({}); + it('should call invoiceTicketsAndPdf if the ticket is invoiceable', async() => { + const ticketId = 10; + const weight = 25; - // try { - // const opts = {transaction: tx}; + spyOn(models.Client, 'findById').and.returnValue({ + hasDailyInvoice: true, + salesPersonUser: () => ({id: 1}) + }); + spyOn(models.TicketState, 'findOne').and.returnValue({alertLevel: 3}); + spyOn(models.Ticket, 'rawSql').and.returnValue([{taxArea: 'WORLD'}]); + spyOn(models.Ticket, 'invoiceTicketsAndPdf').and.returnValue([10]); - // const ticketId = 4; - // const weight = 25; + const invoiceIds = await models.Ticket.setWeight(ctx, ticketId, weight, opts); - // // Mock the necessary methods and data - // jest.spyOn(models.ACL, 'checkAccessAcl').mockResolvedValue(true); - // jest.spyOn(models.Client, 'findById').mockResolvedValue({ - // hasDailyInvoice: true, - // salesPersonUser: () => ({id: 1}) - // }); - // jest.spyOn(models.State, 'findOne').mockResolvedValue({alertLevel: 2}); - // jest.spyOn(models.TicketState, 'findOne').mockResolvedValue({alertLevel: 3}); - // jest.spyOn(models.Ticket, 'rawSql').mockResolvedValue([{taxArea: 'WORLD'}]); - // jest.spyOn(models.Ticket, 'invoiceTicketsAndPdf').mockResolvedValue([1001]); - - // const invoiceIds = await models.Ticket.setWeight(ctx, ticketId, weight, opts); - - // expect(invoiceIds).toEqual([1001]); - - // await tx.rollback(); - // } catch (e) { - // await tx.rollback(); - // throw e; - // } - // }); + expect(invoiceIds.length).toBeGreaterThan(0); + }); }); From 03d711b694c4af992449f6f218bf5c997eb5b284 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 5 Sep 2024 09:12:52 +0200 Subject: [PATCH 043/137] chore: refs #7524 add select limit --- db/dump/fixtures.before.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 56450b27c..c8bbd035d 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3967,3 +3967,7 @@ VALUES (4, 'Referencia Transferencias', 'trnRef'), (5, 'Referencia Nominas', 'payRef'), (6, 'ABA', 'aba'); + +INSERT IGNORE INTO ormConfig + SET id =1, + selectLimit = 1000; \ No newline at end of file From 684658bb966766ad0a3d7bd5175a3ab7709e38a2 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 5 Sep 2024 14:25:50 +0200 Subject: [PATCH 044/137] feat: refs #7929 quitar codigo --- .../11213-aquaCarnation/00-firstScript.sql | 126 +----------------- 1 file changed, 1 insertion(+), 125 deletions(-) diff --git a/db/versions/11213-aquaCarnation/00-firstScript.sql b/db/versions/11213-aquaCarnation/00-firstScript.sql index 3067ce06e..b23a6c782 100644 --- a/db/versions/11213-aquaCarnation/00-firstScript.sql +++ b/db/versions/11213-aquaCarnation/00-firstScript.sql @@ -125,129 +125,5 @@ INSERT IGNORE INTO `material` (`name`) VALUES ('Plumas'); INSERT IGNORE INTO `material` (`name`) VALUES ('Protección Uva'); INSERT IGNORE INTO `material` (`name`) VALUES ('Purpurina'); -CREATE TABLE IF NOT EXISTS `secondaryMaterial` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; - -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Abedul'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acacia'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acero'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acero Galvanizado'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acetato'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Acrílico'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Alambre'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Algodón'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Aluminio'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Antracita'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Arcilla'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Bambú'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Banano'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Canneté'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cartón'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cartulina'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Celofán'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cemento'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cera'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cerámica'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Chapa'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Chenilla'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cloruro de polivinilo'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cobre'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Corcho'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cordel'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cotton'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cotton Chess'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cristal'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cubo Asa'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cuerda'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Cuero'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Doble Raso'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Doble Velvet'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Eco Glass'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Encaje'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Esparto'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Espuma'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Felpa'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Fibra'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Fibra de Coco'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Fibra de Vidrio y Resina'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Fieltro'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Foam'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Gamuza'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Gasa'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Glass'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Goma'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Grafito'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Hierro'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Hoja Carbono'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Hoja de Mirto'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Hormigón'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Jute'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Kraft'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Lana'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Látex'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Latrix'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Lienzo'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Lino'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Lurex'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Madera'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Metacrilato'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Metal'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Mimbre'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Musgo'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Nonwoven'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Nylon'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Organza'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Paja'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Pana'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Papel'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Paperweb'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Paulownia'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Peluche'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Piedra'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Pizarra'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Plástico'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Poliestireno'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Polipropileno'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Poliresina'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Polyester'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Porcelana'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Puntilla'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('PVC'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rafia'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rama'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Raso'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rattan'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rayon'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Reciclable'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Red'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Resina'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Roca'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Rope'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Saco'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Salim'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Seagrass'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Silicona'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Sisal'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Tejido'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Tela'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Terciopelo'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Terracota'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Textil'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Titanio'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Tul'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Velvet'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Vidrio'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Yute'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Zinc'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Base de goma'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Base de madera'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Plumas'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Protección Uva'); -INSERT IGNORE INTO `secondaryMaterial` (`name`) VALUES ('Purpurina'); - UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name= 'Material'; -UPDATE vn.tag SET isFree=0,sourceTable='secondaryMaterial' WHERE name='Material secundario'; \ No newline at end of file +UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name='Material secundario'; \ No newline at end of file From 3e4caa8edf5f4633aedaa7bb591bb15549113d26 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 5 Sep 2024 14:38:55 +0200 Subject: [PATCH 045/137] feat: refs #7929 autoincrement 1 --- db/versions/11213-aquaCarnation/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11213-aquaCarnation/00-firstScript.sql b/db/versions/11213-aquaCarnation/00-firstScript.sql index b23a6c782..9e744b66c 100644 --- a/db/versions/11213-aquaCarnation/00-firstScript.sql +++ b/db/versions/11213-aquaCarnation/00-firstScript.sql @@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS `material` ( `name` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; INSERT IGNORE INTO `material` (`name`) VALUES ('Abedul'); INSERT IGNORE INTO `material` (`name`) VALUES ('Acacia'); From a7bc58a5bc6374e9c9227ff9ab376a7ea0e332dd Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 5 Sep 2024 14:45:17 +0200 Subject: [PATCH 046/137] fix: refs #7931 Immediately discount order lines from available --- .../cache/procedures/available_refresh.sql | 7 +++++- .../cache/procedures/available_updateItem.sql | 23 +++++++++++++++++++ .../hedera/procedures/order_addItem.sql | 10 ++++---- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 db/routines/cache/procedures/available_updateItem.sql diff --git a/db/routines/cache/procedures/available_refresh.sql b/db/routines/cache/procedures/available_refresh.sql index abf023a41..87c003648 100644 --- a/db/routines/cache/procedures/available_refresh.sql +++ b/db/routines/cache/procedures/available_refresh.sql @@ -1,5 +1,10 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`( + OUT `vCalc` INT, + `vRefresh` INT, + `vWarehouse` INT, + `vDated` DATE +) proc: BEGIN DECLARE vStartDate DATE; DECLARE vReserveDate DATETIME; diff --git a/db/routines/cache/procedures/available_updateItem.sql b/db/routines/cache/procedures/available_updateItem.sql new file mode 100644 index 000000000..347eaa137 --- /dev/null +++ b/db/routines/cache/procedures/available_updateItem.sql @@ -0,0 +1,23 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_updateItem`( + `vItem` INT, + `vWarehouse` INT, + `vDated` DATE, + `vQuantity` INT +) +BEGIN + DECLARE vCalc INT; + + SELECT id INTO vCalc FROM cache_calc + WHERE cacheName = 'available' + AND params = CONCAT_WS('/', vWarehouse, vDated) + AND last_refresh <= NOW(); + + IF vCalc IS NOT NULL THEN + UPDATE available + SET available = available - vQuantity + WHERE calc_id = vCalc + AND item_id = vItem; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/hedera/procedures/order_addItem.sql b/db/routines/hedera/procedures/order_addItem.sql index f690f9aa6..204dcb6bf 100644 --- a/db/routines/hedera/procedures/order_addItem.sql +++ b/db/routines/hedera/procedures/order_addItem.sql @@ -1,8 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_addItem`( vSelf INT, - vWarehouse INT, - vItem INT, + vWarehouse INT, + vItem INT, vAmount INT) BEGIN /** @@ -37,7 +37,7 @@ BEGIN ROLLBACK; RESIGNAL; END; - + CALL order_calcCatalogFromItem(vSelf, vItem); START TRANSACTION; @@ -102,6 +102,8 @@ BEGIN amount = vAdd, price = vPrice; + CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd); + SET vRow = LAST_INSERT_ID(); INSERT INTO orderRowComponent (rowFk, componentFk, price) @@ -121,6 +123,6 @@ BEGIN END IF; COMMIT; - CALL vn.ticketCalculatePurge; + CALL vn.ticketCalculatePurge; END$$ DELIMITER ; From c1e086072b7c95addf1d40f08321444f386f1868 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 5 Sep 2024 14:50:36 +0200 Subject: [PATCH 047/137] fix: refs #7524 load after get client --- modules/client/front/balance/create/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 9113d7605..f4ff0e3aa 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -23,6 +23,7 @@ class Controller extends Dialog { } set clientFk(value) { + if (!value) return; this.receipt.clientFk = value; const filter = { @@ -32,6 +33,7 @@ class Controller extends Dialog { } }; + this.getAmountPaid(); this.$http.get(`Clients/findOne`, {filter}) .then(res => { this.receipt.email = res.data.email; @@ -50,7 +52,6 @@ class Controller extends Dialog { set companyFk(value) { this.receipt.companyFk = value; - this.getAmountPaid(); } set description(value) { @@ -152,7 +153,7 @@ class Controller extends Dialog { getAmountPaid() { const filter = { where: { - clientFk: this.$params.id, + clientFk: this.$params.id ?? this.clientFk, companyFk: this.receipt.companyFk } }; @@ -210,8 +211,8 @@ ngModule.vnComponent('vnClientBalanceCreate', { payed: ' Date: Thu, 5 Sep 2024 15:47:45 +0200 Subject: [PATCH 048/137] fix: refs #7524 add fixture orm config --- db/dump/fixtures.before.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 769c081c5..9f590233f 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3953,3 +3953,7 @@ VALUES (4, 'Referencia Transferencias', 'trnRef'), (5, 'Referencia Nominas', 'payRef'), (6, 'ABA', 'aba'); + +INSERT INTO vn.ormConfig SET + id = 1, + selectLimit = 1000; \ No newline at end of file From ac8b101455db4ce37707aeb5c99ab77a169f2e38 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 5 Sep 2024 17:05:48 +0200 Subject: [PATCH 049/137] feat: refs #7898 Modify default --- db/versions/11211-greenCataractarum/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11211-greenCataractarum/00-firstScript.sql b/db/versions/11211-greenCataractarum/00-firstScript.sql index 55b73925c..c9ba73479 100644 --- a/db/versions/11211-greenCataractarum/00-firstScript.sql +++ b/db/versions/11211-greenCataractarum/00-firstScript.sql @@ -1 +1 @@ -ALTER TABLE vn.parking ADD COLUMN floor VARCHAR(5) DEFAULT '--' AFTER row; +ALTER TABLE vn.parking ADD COLUMN floor VARCHAR(5) DEFAULT NULL AFTER row; From 7486c4a3c6d5eefc8046f5997f88d8e0216d7532 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 6 Sep 2024 07:48:53 +0200 Subject: [PATCH 050/137] feat: refs #7562 refs #7532 Requested changes --- db/dump/fixtures.after.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index b3fcad6af..59730d592 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -7,8 +7,8 @@ SET foreign_key_checks = 0; -- XXX: vn-database -INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled, dateRegex, deprecatedMarkRegex, daysKeepDeprecatedObjects) - VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE, '[0-9]{4}-[0-9]{2}-[0-9]{2}', '__$', 60); +INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) + VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); /* #5483 INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk) From 4daea90b1b6ecc05b43aa1b4411ebe044db5108e Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 6 Sep 2024 08:25:21 +0200 Subject: [PATCH 051/137] feat: refs #7562 refs #7759 Requested changes --- myt.config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/myt.config.yml b/myt.config.yml index ffa4188b2..683090ecc 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -2,6 +2,7 @@ code: vn-database versionSchema: util replace: true sumViews: false +defaultDefiner: vn@localhost mockDate: '2001-01-01 12:00:00' subdir: db schemas: From 747e6a562a218c4e123dc9616b5ab28eea6150ef Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 6 Sep 2024 08:51:41 +0200 Subject: [PATCH 052/137] feat: refs #7747 Delete buyUltimate and buyUltimateFromInterval --- .../cache/procedures/last_buy_refresh.sql | 2 +- db/routines/vn/procedures/buyUltimate.sql | 18 ----------------- .../vn/procedures/buyUltimateFromInterval.sql | 20 ------------------- 3 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 db/routines/vn/procedures/buyUltimate.sql delete mode 100644 db/routines/vn/procedures/buyUltimateFromInterval.sql diff --git a/db/routines/cache/procedures/last_buy_refresh.sql b/db/routines/cache/procedures/last_buy_refresh.sql index 555ae0b8d..86a5e8d8c 100644 --- a/db/routines/cache/procedures/last_buy_refresh.sql +++ b/db/routines/cache/procedures/last_buy_refresh.sql @@ -4,7 +4,7 @@ proc: BEGIN /** * Crea o actualiza la cache con la última compra y fecha de cada * artículo hasta ayer. Para obtener la última compra hasta una fecha - * determinada utilizar el procedimiento vn.buyUltimate(). + * determinada utilizar el procedimiento vn.buy_getUltimate(). * * @param vRefresh %TRUE para forzar el recálculo de la cache */ diff --git a/db/routines/vn/procedures/buyUltimate.sql b/db/routines/vn/procedures/buyUltimate.sql deleted file mode 100644 index 37d4312f6..000000000 --- a/db/routines/vn/procedures/buyUltimate.sql +++ /dev/null @@ -1,18 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buyUltimate`( - vWarehouseFk SMALLINT, - vDated DATE -) -BEGIN -/** - * @deprecated Usar buy_getUltimate - * Calcula las últimas compras realizadas hasta una fecha. - * - * @param vItemFk Id del artículo - * @param vWarehouseFk Id del almacén - * @param vDated Compras hasta fecha - * @return tmp.buyUltimate - */ - CALL buy_getUltimate(NULL, vWarehouseFk, vDated); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql deleted file mode 100644 index 08450470c..000000000 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ /dev/null @@ -1,20 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buyUltimateFromInterval`( - vWarehouseFk SMALLINT, - vStarted DATE, - vEnded DATE -) -BEGIN -/** - * @deprecated Usar buy_getUltimateFromInterval - * Calcula las últimas compras realizadas - * desde un rango de fechas. - * - * @param vWarehouseFk Id del almacén si es NULL se actualizan todos - * @param vStarted Fecha inicial - * @param vEnded Fecha fin - * @return tmp.buyUltimateFromInterval - */ - CALL vn.buy_getUltimateFromInterval(NULL, vWarehouseFk, vStarted, vEnded); -END$$ -DELIMITER ; From 640b45ed995a3e75fadcf3f3931438553f55d7bc Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 6 Sep 2024 09:06:00 +0200 Subject: [PATCH 053/137] fix: refs #7931 Apply PR change requests --- .../cache/procedures/available_updateItem.sql | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/db/routines/cache/procedures/available_updateItem.sql b/db/routines/cache/procedures/available_updateItem.sql index 347eaa137..8e94a9d75 100644 --- a/db/routines/cache/procedures/available_updateItem.sql +++ b/db/routines/cache/procedures/available_updateItem.sql @@ -6,12 +6,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_update `vQuantity` INT ) BEGIN +/** + * Immediately deduct/add an amount from the available cache (if exists). + * + * @param vItem The item id + * @param vWarehouse The warehouse id + * @param vDated Available cache date + * @param vQuantity The amount to be deducted from the cache + */ DECLARE vCalc INT; - SELECT id INTO vCalc FROM cache_calc + SELECT id INTO vCalc + FROM cache_calc WHERE cacheName = 'available' - AND params = CONCAT_WS('/', vWarehouse, vDated) - AND last_refresh <= NOW(); + AND params = CONCAT_WS('/', vWarehouse, vDated); IF vCalc IS NOT NULL THEN UPDATE available From 78a851336fe14918b8d390225e45c6a13bab0511 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 09:11:20 +0200 Subject: [PATCH 054/137] chore: refs #7323 worker changes wip --- db/dump/fixtures.before.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 56450b27c..cdc60981d 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -108,6 +108,7 @@ INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`) UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9; UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18; +UPDATE `vn`.`worker` SET bossFk = 50 WHERE id = 49; DELETE FROM `vn`.`worker` WHERE firstName ='customer'; From 48f94140e265cadc274833ef0004dfae66b73273 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 6 Sep 2024 09:16:22 +0200 Subject: [PATCH 055/137] fix: refs #7931 Back test fix --- .../item/back/methods/item/specs/getVisibleAvailable.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js index 61bf6b3e7..f068a3a32 100644 --- a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js +++ b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js @@ -12,7 +12,7 @@ describe('item getVisibleAvailable()', () => { const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); - expect(result.available).toEqual(185); + expect(result.available).toEqual(175); expect(result.visible).toEqual(92); await tx.rollback(); From 46a4b577ce911c06ebb3eb252b8508ecb606c60d Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 6 Sep 2024 10:07:46 +0200 Subject: [PATCH 056/137] feat: refs #7277 test with warehouse --- .../methods/invoiceOut/refundAndInvoice.js | 8 +++- .../invoiceOut/specs/refundAndInvoice.spec.js | 39 ++++++++++++++++++- .../back/methods/invoiceOut/transfer.js | 1 + 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/refundAndInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/refundAndInvoice.js index 7c7788459..41a645ff3 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/refundAndInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/refundAndInvoice.js @@ -9,6 +9,11 @@ module.exports = Self => { required: true, description: 'Issued invoice id' }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true + }, { arg: 'cplusRectificationTypeFk', type: 'number', @@ -38,6 +43,7 @@ module.exports = Self => { Self.refundAndInvoice = async( ctx, id, + withWarehouse, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk, @@ -59,7 +65,7 @@ module.exports = Self => { try { const originalInvoice = await models.InvoiceOut.findById(id, myOptions); - const refundedTickets = await Self.refund(ctx, originalInvoice.ref, false, myOptions); + const refundedTickets = await Self.refund(ctx, originalInvoice.ref, withWarehouse, myOptions); const invoiceCorrection = { correctedFk: id, diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refundAndInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refundAndInvoice.spec.js index c54ae5f6c..ed15fb404 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/refundAndInvoice.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refundAndInvoice.spec.js @@ -14,14 +14,16 @@ describe('InvoiceOut refundAndInvoice()', () => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: activeCtx}); }); - it('should refund an invoice and create a new invoice', async() => { + it('should refund an invoice and create a new invoice with warehouse', async() => { const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; + const withWarehouse = true; try { const result = await models.InvoiceOut.refundAndInvoice( ctx, id, + withWarehouse, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk, @@ -32,7 +34,40 @@ describe('InvoiceOut refundAndInvoice()', () => { expect(result.refundId).toBeDefined(); const invoicesAfter = await models.InvoiceOut.find({where: {id: result.refundId}}, options); - const ticketsAfter = await models.Ticket.find({where: {refFk: 'R10100001'}}, options); + const ticketsAfter = await models.Ticket.find( + {where: {refFk: 'R10100001', warehouse: {neq: null}}}, options); + + expect(invoicesAfter.length).toBeGreaterThan(0); + expect(ticketsAfter.length).toBeGreaterThan(0); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should refund an invoice and create a new invoice with warehouse null', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + const withWarehouse = false; + + try { + const result = await models.InvoiceOut.refundAndInvoice( + ctx, + id, + withWarehouse, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + options + ); + + expect(result).toBeDefined(); + expect(result.refundId).toBeDefined(); + + const invoicesAfter = await models.InvoiceOut.find({where: {id: result.refundId}}, options); + const ticketsAfter = await models.Ticket.find({where: {refFk: 'R10100001', warehouse: null}}, options); expect(invoicesAfter.length).toBeGreaterThan(0); expect(ticketsAfter.length).toBeGreaterThan(0); diff --git a/modules/invoiceOut/back/methods/invoiceOut/transfer.js b/modules/invoiceOut/back/methods/invoiceOut/transfer.js index 954adf780..aa5c0d9d2 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/transfer.js +++ b/modules/invoiceOut/back/methods/invoiceOut/transfer.js @@ -75,6 +75,7 @@ module.exports = Self => { await Self.refundAndInvoice( ctx, id, + false, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk, From b0abe829b1adef052ff723c5e316be34eac29b2a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 6 Sep 2024 10:10:41 +0200 Subject: [PATCH 057/137] fix: refs ##7905 Handle error --- loopback/locale/es.json | 5 +++-- modules/entry/back/methods/entry/getBuysCsv.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8c11b3f1c..8b443d96b 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -371,5 +371,6 @@ "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", "The entry not have stickers": "La entrada no tiene etiquetas", "Too many records": "Demasiados registros", - "Original invoice not found": "Factura original no encontrada" -} + "Original invoice not found": "Factura original no encontrada", + "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe" +} \ No newline at end of file diff --git a/modules/entry/back/methods/entry/getBuysCsv.js b/modules/entry/back/methods/entry/getBuysCsv.js index a46f09c66..4bd246fa0 100644 --- a/modules/entry/back/methods/entry/getBuysCsv.js +++ b/modules/entry/back/methods/entry/getBuysCsv.js @@ -1,5 +1,6 @@ const {toCSV} = require('vn-loopback/util/csv'); const {flatten} = require('vn-loopback/util/flatten'); +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('getBuysCsv', { @@ -36,6 +37,7 @@ module.exports = Self => { Self.getBuysCsv = async(ctx, id, options) => { const data = await Self.getBuys(ctx, id, null, options); + if (!data.length) throw new UserError('The entry has no lines or does not exist'); const dataFlatted = flatten(data); return [toCSV(dataFlatted), 'text/csv', `inline; filename="buys-${id}.csv"`]; }; From 18d93d93a609daf2f215a48cba19ef1c68dce28f Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 10:40:16 +0200 Subject: [PATCH 058/137] chore: refs #7323 worker changes --- .../11215-purpleIvy/00-firstScript.sql | 4 ++ loopback/server/boot/role-resolver.js | 12 ++++++ modules/worker/back/models/worker.json | 40 ++++++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 db/versions/11215-purpleIvy/00-firstScript.sql create mode 100644 loopback/server/boot/role-resolver.js diff --git a/db/versions/11215-purpleIvy/00-firstScript.sql b/db/versions/11215-purpleIvy/00-firstScript.sql new file mode 100644 index 000000000..ac82b7773 --- /dev/null +++ b/db/versions/11215-purpleIvy/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES ('Worker', '__get__descriptor', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'findById', 'READ', 'ALLOW', 'ROLE', '$subordinate'); \ No newline at end of file diff --git a/loopback/server/boot/role-resolver.js b/loopback/server/boot/role-resolver.js new file mode 100644 index 000000000..cf70abb39 --- /dev/null +++ b/loopback/server/boot/role-resolver.js @@ -0,0 +1,12 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = async function(app) { + const models = app.models; + + models.VnRole.registerResolver('$subordinate', async(role, ctx) => { + Object.assign(ctx, {req: {accessToken: {userId: ctx.accessToken.userId}}}); + + const isSubordinate = await models.Worker.isSubordinate(ctx, +ctx.modelId); + if (!isSubordinate) throw new UserError(`You don't have enough privileges`); + }); +}; diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 855d77e39..b809768a4 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -140,5 +140,41 @@ "principalType": "ROLE", "principalId": "$owner" } - ] -} + ], + "scopes": { + "descriptor": { + "include": [ + { + "relation": "user", + "scope": { + "fields": [ + "name", + "nickname" + ], + "include": { + "relation": "emailUser", + "scope": { + "fields": [ + "email" + ] + } + } + } + }, + { + "relation": "department", + "scope": { + "include": [ + { + "relation": "department" + } + ] + } + }, + { + "relation": "sip" + } + ] + } + } +} \ No newline at end of file From d44dec3703dca6f6182ce9cdbf20dfdc07a5a52c Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 6 Sep 2024 11:25:49 +0200 Subject: [PATCH 059/137] fix: refs #7931 Back test fix --- .../item/back/methods/item/specs/getVisibleAvailable.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js index f068a3a32..61bf6b3e7 100644 --- a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js +++ b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js @@ -12,7 +12,7 @@ describe('item getVisibleAvailable()', () => { const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); - expect(result.available).toEqual(175); + expect(result.available).toEqual(185); expect(result.visible).toEqual(92); await tx.rollback(); From 382e54b57220c36c2e29065986cb3fbf0f78999f Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 6 Sep 2024 11:30:43 +0200 Subject: [PATCH 060/137] fix: refs #7931 Back test fix --- .../item/back/methods/item/specs/getVisibleAvailable.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js index 61bf6b3e7..f068a3a32 100644 --- a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js +++ b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js @@ -12,7 +12,7 @@ describe('item getVisibleAvailable()', () => { const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); - expect(result.available).toEqual(185); + expect(result.available).toEqual(175); expect(result.visible).toEqual(92); await tx.rollback(); From 99ce15863291525340c4c35677776906c033d933 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 11:33:15 +0200 Subject: [PATCH 061/137] chore: refs #7663 return correct type --- modules/ticket/back/methods/ticket/setWeight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index d71f2c0e5..47087d384 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -17,7 +17,7 @@ module.exports = Self => { description: 'The weight value', }], returns: { - type: 'boolean', + type: 'Array', root: true }, http: { From d10db686e536df72cb982b8d811702f5425c4b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 6 Sep 2024 12:52:24 +0200 Subject: [PATCH 062/137] fix: refs #7346 ticket_close serial --- db/routines/vn/procedures/ticket_close.sql | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/ticket_close.sql b/db/routines/vn/procedures/ticket_close.sql index 97da5057c..f8bbe239b 100644 --- a/db/routines/vn/procedures/ticket_close.sql +++ b/db/routines/vn/procedures/ticket_close.sql @@ -17,6 +17,7 @@ BEGIN DECLARE vHasDailyInvoice BOOL; DECLARE vWithPackage BOOL; DECLARE vHasToInvoice BOOL; + DECLARE vSerial VARCHAR(2); DECLARE cur CURSOR FOR SELECT ticketFk FROM tmp.ticket_close; @@ -83,14 +84,17 @@ BEGIN GROUP BY e.freightItemFk); IF(vHasDailyInvoice) AND vHasToInvoice THEN + SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial; + IF NOT vSerial THEN + CALL util.throw('Cannot booking without a serial'); + END IF; - -- Facturacion rapida CALL ticket_setState(vCurTicketFk, 'DELIVERED'); - -- Facturar si está contabilizado + IF vIsTaxDataChecked THEN CALL invoiceOut_newFromClient( vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'multiple')), + vSerial, vShipped, vCompanyFk, NULL, From e2c6a4575610e89c29cc32e9e6718af45189befb Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 6 Sep 2024 12:57:57 +0200 Subject: [PATCH 063/137] fix: refs #7931 Available back test fix --- .../item/back/methods/item/specs/getVisibleAvailable.spec.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js index f068a3a32..adf9b7f76 100644 --- a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js +++ b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('item getVisibleAvailable()', () => { - it('should check available visible for today', async() => { + it('should check available visible for tomorrow', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; @@ -9,10 +9,11 @@ describe('item getVisibleAvailable()', () => { const itemFk = 1; const warehouseFk = 1; const dated = Date.vnNew(); + dated.setDate(dated.getDate() + 1); const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); - expect(result.available).toEqual(175); + expect(result.available).toEqual(185); expect(result.visible).toEqual(92); await tx.rollback(); From 0ad4d3a9592dcb8283b3f25ffd39f8c2bcfbdc3b Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 6 Sep 2024 13:50:49 +0200 Subject: [PATCH 064/137] feat: refs #7905 getBuysCsv --- loopback/util/flatten.js | 42 ++++++++++++++++++ .../entry/back/methods/entry/getBuysCsv.js | 44 +++++++++++++++++++ modules/entry/back/models/entry.js | 1 + 3 files changed, 87 insertions(+) create mode 100644 loopback/util/flatten.js create mode 100644 modules/entry/back/methods/entry/getBuysCsv.js diff --git a/loopback/util/flatten.js b/loopback/util/flatten.js new file mode 100644 index 000000000..18d682d1f --- /dev/null +++ b/loopback/util/flatten.js @@ -0,0 +1,42 @@ +/** + * Flattens an array of objects by converting each object into a flat structure. + * + * @param {Array} dataArray Array of objects to be flattened + * @return {Array} Array of flattened objects + */ +function flatten(dataArray) { + return dataArray.map(item => flattenObj(item.__data)); +} + +/** + * Recursively flattens an object, converting nested properties into a single level object + * with keys representing the original nested structure. + * + * @param {Object} data The object to be flattened + * @param {String} [prefix=''] Optional prefix for nested keys + * @return {Object} Flattened object + */ +function flattenObj(data, prefix = '') { + let result = {}; + try { + for (let key in data) { + if (!data[key]) continue; + + const newKey = prefix ? `${prefix}_${key}` : key; + const value = data[key]; + + if (typeof value === 'object' && value !== null && !Array.isArray(value)) + Object.assign(result, flattenObj(value.__data, newKey)); + else + result[newKey] = value; + } + } catch (error) { + console.error(error); + } + + return result; +} +module.exports = { + flatten, + flattenObj, +}; diff --git a/modules/entry/back/methods/entry/getBuysCsv.js b/modules/entry/back/methods/entry/getBuysCsv.js new file mode 100644 index 000000000..4bd246fa0 --- /dev/null +++ b/modules/entry/back/methods/entry/getBuysCsv.js @@ -0,0 +1,44 @@ +const {toCSV} = require('vn-loopback/util/csv'); +const {flatten} = require('vn-loopback/util/flatten'); +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('getBuysCsv', { + description: 'Returns buys for one entry in CSV file format', + accessType: 'READ', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: `/:id/getBuysCsv`, + verb: 'GET' + } + }); + + Self.getBuysCsv = async(ctx, id, options) => { + const data = await Self.getBuys(ctx, id, null, options); + if (!data.length) throw new UserError('The entry has no lines or does not exist'); + const dataFlatted = flatten(data); + return [toCSV(dataFlatted), 'text/csv', `inline; filename="buys-${id}.csv"`]; + }; +}; diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index b11d64415..8ca79f531 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -3,6 +3,7 @@ module.exports = Self => { require('../methods/entry/filter')(Self); require('../methods/entry/getEntry')(Self); require('../methods/entry/getBuys')(Self); + require('../methods/entry/getBuysCsv')(Self); require('../methods/entry/importBuys')(Self); require('../methods/entry/importBuysPreview')(Self); require('../methods/entry/lastItemBuys')(Self); From 901cdc7117b1ac701447762c23f1a5846c93400d Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 14:18:15 +0200 Subject: [PATCH 065/137] feat: refs #4074 modify acls --- .../11216-salmonPaniculata/00-firstScript.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/versions/11216-salmonPaniculata/00-firstScript.sql diff --git a/db/versions/11216-salmonPaniculata/00-firstScript.sql b/db/versions/11216-salmonPaniculata/00-firstScript.sql new file mode 100644 index 000000000..956dcc25b --- /dev/null +++ b/db/versions/11216-salmonPaniculata/00-firstScript.sql @@ -0,0 +1,12 @@ +-- Place your SQL code here +DELETE FROM salix.ACL WHERE model = 'Province' LIMIT 1; +DELETE FROM salix.ACL WHERE model = 'Town' LIMIT 1; + +UPDATE salix.ACL SET accessType = 'READ' WHERE model = 'BankEntity'; +INSERT INTO salix.ACL + SET model = 'BankEntity', + property = '*', + accessType = 'WRITE', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'financial'; From 37fabc38bd99da9b6d8755fc59306424586b1cb2 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 6 Sep 2024 14:56:14 +0200 Subject: [PATCH 066/137] fix(hedera): refs #7931 PROC order_addItem NULL available fix, translations added --- .../hedera/procedures/order_addItem.sql | 6 +++++- .../11217-greenDracena/00-hederaMessages.sql | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/versions/11217-greenDracena/00-hederaMessages.sql diff --git a/db/routines/hedera/procedures/order_addItem.sql b/db/routines/hedera/procedures/order_addItem.sql index 204dcb6bf..1470ddf35 100644 --- a/db/routines/hedera/procedures/order_addItem.sql +++ b/db/routines/hedera/procedures/order_addItem.sql @@ -47,11 +47,15 @@ BEGIN FROM tmp.zoneGetShipped WHERE warehouseFk = vWarehouse; - SELECT IFNULL(available, 0) INTO vAvailable + SELECT available INTO vAvailable FROM tmp.ticketLot WHERE warehouseFk = vWarehouse AND itemFk = vItem; + IF vAvailable IS NULL THEN + SET vAvailable = 0; + END IF; + IF vAmount > vAvailable THEN CALL util.throw ('ORDER_ROW_UNAVAILABLE'); END IF; diff --git a/db/versions/11217-greenDracena/00-hederaMessages.sql b/db/versions/11217-greenDracena/00-hederaMessages.sql new file mode 100644 index 000000000..f6c9bdce3 --- /dev/null +++ b/db/versions/11217-greenDracena/00-hederaMessages.sql @@ -0,0 +1,19 @@ +INSERT INTO hedera.message (code,description) + VALUES ('ORDER_ROW_UNAVAILABLE','The ordered quantity exceeds the available'); +INSERT INTO hedera.message (code,description) + VALUES ('AMOUNT_NOT_MATCH_GROUPING','The quantity ordered does not match the grouping'); + +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('ORDER_ROW_UNAVAILABLE','es','La cantidad pedida excede el disponible'); +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('AMOUNT_NOT_MATCH_GROUPING','es','La cantidad pedida no coincide con el agrupado'); + +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('ORDER_ROW_UNAVAILABLE','fr','La quantité demandée dépasse ce qui est disponible'); +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('AMOUNT_NOT_MATCH_GROUPING','fr','La quantité commandée ne correspond pas au regroupement'); + +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('ORDER_ROW_UNAVAILABLE','pt','A quantidade de entrega excede a disponibilidade'); +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('AMOUNT_NOT_MATCH_GROUPING','pt','A quantidade solicitada não corresponde ao agrupamento'); From eb11e18df52000d1ecd45e7d6d01fa4924b6933b Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 16:01:26 +0200 Subject: [PATCH 067/137] fix: refs #7323 fetch from right source --- modules/worker/front/descriptor/index.js | 38 ++---------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 75265acb4..4860163c1 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -36,42 +36,8 @@ class Controller extends Descriptor { } loadData() { - const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'emailVerified'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { - relation: 'client', - scope: { - fields: ['fi'] - } - }, { - relation: 'sip', - scope: { - fields: ['extension'] - } - }, { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } - } - ] - }; - - return this.getData(`Workers/${this.id}`, {filter}) - .then(res => this.entity = res.data); + return this.getData('Workers/descriptor', {filter: {where: {id: this.id}}}) + .then(res => this.entity = res.data[0]); } getPassRequirements() { From 6065c056e20da91f3f8984f8159cf0d15a2e29fc Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 16:04:40 +0200 Subject: [PATCH 068/137] chore: refs #7323 fix test --- modules/worker/front/descriptor/index.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js index 4f7fa6a05..e7eec86d3 100644 --- a/modules/worker/front/descriptor/index.spec.js +++ b/modules/worker/front/descriptor/index.spec.js @@ -17,7 +17,7 @@ describe('vnWorkerDescriptor', () => { const response = 'foo'; $httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); - $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); + $httpBackend.expectRoute('GET', 'Workers/descriptor').respond(response); controller.id = id; $httpBackend.flush(); From 0a4bd0f2d51f4950b46b67e2fd54ab0d120a825e Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 16:09:29 +0200 Subject: [PATCH 069/137] chore: refs #7323 fix test --- modules/worker/front/descriptor/index.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js index e7eec86d3..8797c8b4a 100644 --- a/modules/worker/front/descriptor/index.spec.js +++ b/modules/worker/front/descriptor/index.spec.js @@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => { describe('loadData()', () => { it(`should perform a get query to store the worker data into the controller`, () => { const id = 1; - const response = 'foo'; + const response = ['foo']; $httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); $httpBackend.expectRoute('GET', 'Workers/descriptor').respond(response); controller.id = id; $httpBackend.flush(); - expect(controller.worker).toEqual(response); + expect(controller.worker).toEqual(response[0]); }); }); From ba2c5cb209c999baa11d0aa57024900c27f1515e Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 17:49:45 +0200 Subject: [PATCH 070/137] chore: refs #7323 filter data --- modules/worker/back/models/worker.json | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index b809768a4..82cd1cc2d 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -143,6 +143,10 @@ ], "scopes": { "descriptor": { + "fields": [ + "id", + "phone" + ], "include": [ { "relation": "user", @@ -164,15 +168,29 @@ { "relation": "department", "scope": { + "fields": [ + "departmentFk" + ], "include": [ { - "relation": "department" + "relation": "department", + "scope": { + "fields": [ + "id", + "name" + ] + } } ] } }, { - "relation": "sip" + "relation": "sip", + "scope": { + "fields": [ + "extension" + ] + } } ] } From dbd8f945552609cf8dde82a18af48aa1fe33b985 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 8 Sep 2024 12:49:55 +0200 Subject: [PATCH 071/137] perf: refs #7671 improve showBadDates --- db/dump/dump.after.sql | 1 + modules/item/back/methods/fixed-price/filter.js | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/db/dump/dump.after.sql b/db/dump/dump.after.sql index 7508a36a7..a7de86efc 100644 --- a/db/dump/dump.after.sql +++ b/db/dump/dump.after.sql @@ -1,4 +1,5 @@ CREATE USER 'vn'@'localhost'; +INSERT INTO `ormConfig`(`id`,`selectLimit`) VALUES(1,1000); GRANT SELECT, INSERT, diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index 838e913bf..f8cbfb5eb 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -186,12 +186,12 @@ module.exports = Self => { } if (ctx.req.query.showBadDates === 'true') { stmt.merge({ - sql: `WHERE - fp.started> util.VN_CURDATE() `}); - } - - stmt.merge(conn.makeSuffix(filter)); - + sql: ` WHERE + fp.started> util.VN_CURDATE() `}); + } else + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge(conn.makeOrderBy(filter.order)); + stmt.merge(conn.makeLimit(filter)); const fixedPriceIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); From 5c4a30f2f9873d7c38c780205e07545a750443fa Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 8 Sep 2024 12:50:32 +0200 Subject: [PATCH 072/137] perf: refs #7671 improve showBadDates --- db/dump/dump.after.sql | 1 - modules/item/back/methods/fixed-price/filter.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/db/dump/dump.after.sql b/db/dump/dump.after.sql index a7de86efc..7508a36a7 100644 --- a/db/dump/dump.after.sql +++ b/db/dump/dump.after.sql @@ -1,5 +1,4 @@ CREATE USER 'vn'@'localhost'; -INSERT INTO `ormConfig`(`id`,`selectLimit`) VALUES(1,1000); GRANT SELECT, INSERT, diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index f8cbfb5eb..addc7027d 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -136,7 +136,7 @@ module.exports = Self => { SELECT DISTINCT fp.id, fp.itemFk, fp.warehouseFk, - w.name as warehouseName, + w.name warehouseName, fp.rate2, fp.rate3, fp.started, From 632d3190b1fc93f8bf7c59df3cffea56e5753e73 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 9 Sep 2024 07:49:22 +0200 Subject: [PATCH 073/137] feat: refs #7938 remove unnecessary insert in clientLog --- modules/ticket/back/methods/ticket/closure.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 89343b193..4622ba271 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -171,16 +171,6 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { {userId}, ); - const oldInstance = `{"email": "${ticket.recipient}"}`; - const newInstance = `{"email": ""}`; - await Self.rawSql( - ` - INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) - VALUES (?, NULL, 'UPDATE', 'Client', ?, ?)`, - [ticket.clientFk, oldInstance, newInstance], - {userId}, - ); - const body = `No se ha podido enviar el albarán ${ticket.id} al cliente ${ticket.clientFk} - ${ticket.clientName} porque la dirección de email "${ticket.recipient}" no es correcta From c4527cc5c56dd0382e710db4b99e6ba47371115d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 08:28:27 +0200 Subject: [PATCH 074/137] feat: refs #4515 New throw buy_checkItem --- .../{buy_chekItem.sql => buy_checkItem.sql} | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) rename db/routines/vn/procedures/{buy_chekItem.sql => buy_checkItem.sql} (63%) diff --git a/db/routines/vn/procedures/buy_chekItem.sql b/db/routines/vn/procedures/buy_checkItem.sql similarity index 63% rename from db/routines/vn/procedures/buy_chekItem.sql rename to db/routines/vn/procedures/buy_checkItem.sql index e9e9336b7..1144db889 100644 --- a/db/routines/vn/procedures/buy_chekItem.sql +++ b/db/routines/vn/procedures/buy_checkItem.sql @@ -6,9 +6,10 @@ BEGIN * * @param tmp.buysToCheck(id as INT). */ - DECLARE hasVolumetricAgency INT; + DECLARE vHasVolumetricAgency INT; + DECLARE vItemFk INT; - SELECT a.hasWeightVolumetric INTO hasVolumetricAgency + SELECT a.hasWeightVolumetric, i.id INTO vHasVolumetricAgency, vItemFk FROM entry e JOIN travel t ON t.id = e.travelFk JOIN agencyMode a ON a.id = t.agencyModeFk @@ -19,10 +20,10 @@ BEGIN AND a.hasWeightVolumetric LIMIT 1; - DROP TEMPORARY TABLE tmp.buysToCheck; + DROP TEMPORARY TABLE tmp.buysToCheck; - IF hasVolumetricAgency THEN - CALL util.throw('Item lacks size/weight in purchase line at agency'); - END IF; + IF vHasVolumetricAgency THEN + CALL util.throw(CONCAT('Missing size/weight in buy line at agency, item: ', vItemFk)); + END IF; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; From 56eb3e093d8058b5e71eb31d54ba51ee61023709 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 09:39:10 +0200 Subject: [PATCH 075/137] feat: refs #6727 Added indexes in creationDate --- .../11107-pinkAspidistra/00-firstScript.sql | 23 ++----------------- .../11107-pinkAspidistra/01-firstScript.sql | 1 + .../11107-pinkAspidistra/02-firstScript.sql | 1 + .../11107-pinkAspidistra/03-firstScript.sql | 1 + .../11107-pinkAspidistra/04-firstScript.sql | 1 + .../11107-pinkAspidistra/05-firstScript.sql | 1 + .../11107-pinkAspidistra/06-firstScript.sql | 1 + .../11107-pinkAspidistra/07-firstScript.sql | 1 + .../11107-pinkAspidistra/08-firstScript.sql | 1 + .../11107-pinkAspidistra/09-firstScript.sql | 1 + .../11107-pinkAspidistra/10-firstScript.sql | 1 + .../11107-pinkAspidistra/11-firstScript.sql | 1 + .../11107-pinkAspidistra/12-firstScript.sql | 1 + .../11107-pinkAspidistra/13-firstScript.sql | 1 + .../11107-pinkAspidistra/14-firstScript.sql | 1 + .../11107-pinkAspidistra/15-firstScript.sql | 1 + .../11107-pinkAspidistra/16-firstScript.sql | 1 + .../11107-pinkAspidistra/17-firstScript.sql | 1 + .../11107-pinkAspidistra/18-firstScript.sql | 1 + .../11107-pinkAspidistra/19-firstScript.sql | 1 + .../11107-pinkAspidistra/20-firstScript.sql | 1 + .../11107-pinkAspidistra/21-firstScript.sql | 1 + .../11107-pinkAspidistra/22-firstScript.sql | 1 + .../11107-pinkAspidistra/23-firstScript.sql | 1 + .../11107-pinkAspidistra/24-firstScript.sql | 1 + 25 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 db/versions/11107-pinkAspidistra/01-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/02-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/03-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/04-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/05-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/06-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/07-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/08-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/09-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/10-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/11-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/12-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/13-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/14-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/15-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/16-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/17-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/18-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/19-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/20-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/21-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/22-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/23-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/24-firstScript.sql diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql index 3ed3df526..62af9c306 100644 --- a/db/versions/11107-pinkAspidistra/00-firstScript.sql +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -9,24 +9,5 @@ CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`) - VALUES - ('account', 'roleLog' ), - ('account', 'userLog' ), - ('vn', 'entryLog' ), - ('vn', 'clientLog' ), - ('vn', 'itemLog' ), - ('vn', 'shelvingLog' ), - ('vn', 'workerLog' ), - ('vn', 'deviceProductionLog' ), - ('vn', 'zoneLog' ), - ('vn', 'rateLog' ), - ('vn', 'ticketLog' ), - ('vn', 'agencyLog' ), - ('vn', 'userLog' ), - ('vn', 'routeLog' ), - ('vn', 'claimLog' ), - ('vn', 'supplierLog' ), - ('vn', 'invoiceInLog' ), - ('vn', 'travelLog' ), - ('vn', 'packingSiteDeviceLog' ), - ('vn', 'parkingLog' ); + SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.`COLUMNS` + WHERE COLUMN_NAME IN ('newInstance', 'newInstance'); diff --git a/db/versions/11107-pinkAspidistra/01-firstScript.sql b/db/versions/11107-pinkAspidistra/01-firstScript.sql new file mode 100644 index 000000000..426fcc5b8 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/01-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX userLog_creationDate_IDX USING BTREE ON account.userLog (creationDate DESC); diff --git a/db/versions/11107-pinkAspidistra/02-firstScript.sql b/db/versions/11107-pinkAspidistra/02-firstScript.sql new file mode 100644 index 000000000..e916754e3 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/02-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX roleLog_creationDate_IDX USING BTREE ON account.roleLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/03-firstScript.sql b/db/versions/11107-pinkAspidistra/03-firstScript.sql new file mode 100644 index 000000000..f7400c866 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/03-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX ACLLog_creationDate_IDX USING BTREE ON salix.ACLLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/04-firstScript.sql b/db/versions/11107-pinkAspidistra/04-firstScript.sql new file mode 100644 index 000000000..0c118284e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/04-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX supplierLog_creationDate_IDX USING BTREE ON vn.supplierLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/05-firstScript.sql b/db/versions/11107-pinkAspidistra/05-firstScript.sql new file mode 100644 index 000000000..5cb4070bb --- /dev/null +++ b/db/versions/11107-pinkAspidistra/05-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX deviceProductionLog_creationDate_IDX USING BTREE ON vn.deviceProductionLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/06-firstScript.sql b/db/versions/11107-pinkAspidistra/06-firstScript.sql new file mode 100644 index 000000000..332b8a60a --- /dev/null +++ b/db/versions/11107-pinkAspidistra/06-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX routeLog_creationDate_IDX USING BTREE ON vn.routeLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/07-firstScript.sql b/db/versions/11107-pinkAspidistra/07-firstScript.sql new file mode 100644 index 000000000..b80f8b75f --- /dev/null +++ b/db/versions/11107-pinkAspidistra/07-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX itemLog_creationDate_IDX USING BTREE ON vn.itemLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/08-firstScript.sql b/db/versions/11107-pinkAspidistra/08-firstScript.sql new file mode 100644 index 000000000..315f9b256 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/08-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX userLog_creationDate_IDX USING BTREE ON vn.userLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/09-firstScript.sql b/db/versions/11107-pinkAspidistra/09-firstScript.sql new file mode 100644 index 000000000..7bb604915 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/09-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX invoiceInLog_creationDate_IDX USING BTREE ON vn.invoiceInLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/10-firstScript.sql b/db/versions/11107-pinkAspidistra/10-firstScript.sql new file mode 100644 index 000000000..06e186e0e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/10-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX zoneLog_creationDate_IDX USING BTREE ON vn.zoneLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/11-firstScript.sql b/db/versions/11107-pinkAspidistra/11-firstScript.sql new file mode 100644 index 000000000..be539e7b0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/11-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX clientLog_creationDate_IDX USING BTREE ON vn.clientLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/12-firstScript.sql b/db/versions/11107-pinkAspidistra/12-firstScript.sql new file mode 100644 index 000000000..4abc284b6 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/12-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX workerLog_creationDate_IDX USING BTREE ON vn.workerLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/13-firstScript.sql b/db/versions/11107-pinkAspidistra/13-firstScript.sql new file mode 100644 index 000000000..cc901e13c --- /dev/null +++ b/db/versions/11107-pinkAspidistra/13-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX ticketLog_creationDate_IDX USING BTREE ON vn.ticketLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/14-firstScript.sql b/db/versions/11107-pinkAspidistra/14-firstScript.sql new file mode 100644 index 000000000..02d2a37b0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/14-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX rateLog_creationDate_IDX USING BTREE ON vn.rateLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/15-firstScript.sql b/db/versions/11107-pinkAspidistra/15-firstScript.sql new file mode 100644 index 000000000..ad75ff6d0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/15-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX claimLog_creationDate_IDX USING BTREE ON vn.claimLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/16-firstScript.sql b/db/versions/11107-pinkAspidistra/16-firstScript.sql new file mode 100644 index 000000000..50c7b61a8 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/16-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX saleGroupLog_creationDate_IDX USING BTREE ON vn.saleGroupLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/17-firstScript.sql b/db/versions/11107-pinkAspidistra/17-firstScript.sql new file mode 100644 index 000000000..3de084bcf --- /dev/null +++ b/db/versions/11107-pinkAspidistra/17-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX packingSiteDeviceLog_creationDate_IDX USING BTREE ON vn.packingSiteDeviceLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/18-firstScript.sql b/db/versions/11107-pinkAspidistra/18-firstScript.sql new file mode 100644 index 000000000..1181f8263 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/18-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX travelLog_creationDate_IDX USING BTREE ON vn.travelLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/19-firstScript.sql b/db/versions/11107-pinkAspidistra/19-firstScript.sql new file mode 100644 index 000000000..e95f93031 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/19-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX shelvingLog_creationDate_IDX USING BTREE ON vn.shelvingLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/20-firstScript.sql b/db/versions/11107-pinkAspidistra/20-firstScript.sql new file mode 100644 index 000000000..d3598466d --- /dev/null +++ b/db/versions/11107-pinkAspidistra/20-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX productionConfigLog_creationDate_IDX USING BTREE ON vn.productionConfigLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/21-firstScript.sql b/db/versions/11107-pinkAspidistra/21-firstScript.sql new file mode 100644 index 000000000..5db8d3c63 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/21-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX entryLog_creationDate_IDX USING BTREE ON vn.entryLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/22-firstScript.sql b/db/versions/11107-pinkAspidistra/22-firstScript.sql new file mode 100644 index 000000000..91e68c43b --- /dev/null +++ b/db/versions/11107-pinkAspidistra/22-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX agencyLog_creationDate_IDX USING BTREE ON vn.agencyLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/23-firstScript.sql b/db/versions/11107-pinkAspidistra/23-firstScript.sql new file mode 100644 index 000000000..edd79473e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/23-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX parkingLog_creationDate_IDX USING BTREE ON vn.parkingLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/24-firstScript.sql b/db/versions/11107-pinkAspidistra/24-firstScript.sql new file mode 100644 index 000000000..81e84c405 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/24-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX bufferLog_creationDate_IDX USING BTREE ON srt.bufferLog (creationDate DESC); \ No newline at end of file From 261bebbc3bad07ed317bccbf457d80764efe61d3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 09:41:40 +0200 Subject: [PATCH 076/137] feat: refs #6727 Deleted duplicated indexes --- db/versions/11107-pinkAspidistra/13-firstScript.sql | 1 - .../00-firstScript.sql} | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 db/versions/11107-pinkAspidistra/13-firstScript.sql rename db/versions/{11107-pinkAspidistra/16-firstScript.sql => 11219-goldenCataractarum/00-firstScript.sql} (67%) diff --git a/db/versions/11107-pinkAspidistra/13-firstScript.sql b/db/versions/11107-pinkAspidistra/13-firstScript.sql deleted file mode 100644 index cc901e13c..000000000 --- a/db/versions/11107-pinkAspidistra/13-firstScript.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX ticketLog_creationDate_IDX USING BTREE ON vn.ticketLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/16-firstScript.sql b/db/versions/11219-goldenCataractarum/00-firstScript.sql similarity index 67% rename from db/versions/11107-pinkAspidistra/16-firstScript.sql rename to db/versions/11219-goldenCataractarum/00-firstScript.sql index 50c7b61a8..4c4b9eac5 100644 --- a/db/versions/11107-pinkAspidistra/16-firstScript.sql +++ b/db/versions/11219-goldenCataractarum/00-firstScript.sql @@ -1 +1 @@ -CREATE INDEX saleGroupLog_creationDate_IDX USING BTREE ON vn.saleGroupLog (creationDate DESC); \ No newline at end of file +CREATE INDEX saleGroupLog_creationDate_IDX USING BTREE ON vn.saleGroupLog (creationDate DESC); From 601260494694578df7e0c06e450eb4ef39e08544 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 09:57:38 +0200 Subject: [PATCH 077/137] perf(salix): refs #7671 #7671 imrpove and revert where changes --- modules/item/back/methods/fixed-price/filter.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index addc7027d..3bc8ed6b0 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -128,6 +128,9 @@ module.exports = Self => { return {[param]: value}; } }); + if (ctx.req.query.showBadDates === 'true') + where['fp.started'] = {gte: Date.vnNew()}; + filter = mergeFilters(filter, {where}); const stmts = []; @@ -184,14 +187,8 @@ module.exports = Self => { } } } - if (ctx.req.query.showBadDates === 'true') { - stmt.merge({ - sql: ` WHERE - fp.started> util.VN_CURDATE() `}); - } else - stmt.merge(conn.makeWhere(filter.where)); - stmt.merge(conn.makeOrderBy(filter.order)); - stmt.merge(conn.makeLimit(filter)); + + stmt.merge(conn.makeSuffix(filter)); const fixedPriceIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); From 7710b87f4a84cc5a057d90b2d1b378c74a3b7237 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 10:07:05 +0200 Subject: [PATCH 078/137] test(salix): refs #7671 #7671 improve and revert where changes --- modules/item/back/methods/fixed-price/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index 3bc8ed6b0..488c2441d 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -128,7 +128,7 @@ module.exports = Self => { return {[param]: value}; } }); - if (ctx.req.query.showBadDates === 'true') + if (ctx.req.query?.showBadDates === 'true') where['fp.started'] = {gte: Date.vnNew()}; filter = mergeFilters(filter, {where}); From 723ec2b453b16562ab2868044506ddeb0981a408 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 11:34:42 +0200 Subject: [PATCH 079/137] fix: refs #7844 Filter monitor --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 4 ++-- modules/ticket/back/methods/ticket/filter.js | 2 +- modules/ticket/back/methods/ticket/getTicketsFuture.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 8ef51a0d1..927f49999 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -285,7 +285,7 @@ module.exports = Self => { if (hasProblems === true) { whereProblems = {or: [ {'tp.isFreezed': true}, - {'tp.risk': {lt: 0}}, + {'tp.hasRisk': true}, {'tp.hasTicketRequest': true}, {'tp.hasComponentLack': true}, {'tp.isTaxDataChecked': false}, @@ -295,7 +295,7 @@ module.exports = Self => { } else if (hasProblems === false) { whereProblems = {and: [ {'tp.isFreezed': false}, - {'tp.risk': 0}, + {'tp.hasRisk': false}, {'tp.hasTicketRequest': false}, {'tp.hasComponentLack': false}, {'tp.isTaxDataChecked': true}, diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 2209c8df4..c98ddaab6 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -343,7 +343,7 @@ module.exports = Self => { const problems = {[condition]: [ {'tp.isFreezed': hasProblem}, - {'tp.risk': hasProblem}, + {'tp.hasRisk': hasProblem}, {'tp.hasTicketRequest': hasProblem}, {'tp.itemShortage': range}, {'tp.hasRounding': hasProblem} diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index 9f455ec03..abd269e5e 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -196,7 +196,7 @@ module.exports = Self => { const problems = { [condition]: [ {'tp.isFreezed': hasProblem}, - {'tp.risk': hasProblem}, + {'tp.hasRisk': hasProblem}, {'tp.hasTicketRequest': hasProblem}, {'tp.itemShortage': range}, {'tp.hasComponentLack': hasProblem}, From 31b04cba75e57d98cb0914acec72249a4017f498 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 12:08:12 +0200 Subject: [PATCH 080/137] feat(salix): refs #6156 #6156 Move to myt version --- .../00-ModifyProc_ticket_canAdvance.sql | 128 ------------- .../vn/procedures/ticket_canAdvance.sql | 181 +++++++++--------- .../11221-chocolateSalal/00-firstScript.sql | 12 ++ 3 files changed, 98 insertions(+), 223 deletions(-) delete mode 100644 db/changes/233601/00-ModifyProc_ticket_canAdvance.sql create mode 100644 db/versions/11221-chocolateSalal/00-firstScript.sql diff --git a/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql b/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql deleted file mode 100644 index b0426711f..000000000 --- a/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql +++ /dev/null @@ -1,128 +0,0 @@ -CREATE TABLE IF NOT EXISTS `vn`.`ticketCanAdvanceConfig` ( - `id` INT auto_increment NULL, - `destinationOrder` INT NULL, - CONSTRAINT `ticketCanAdvanceConfig_PK` PRIMARY KEY (id) -) -ENGINE=InnoDB -DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; - -INSERT INTO `vn`.`ticketCanAdvanceConfig` - SET `destinationOrder` = 5; - -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) -BEGIN -/** - * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. - * - * @param vDateFuture Fecha de los tickets que se quieren adelantar. - * @param vDateToAdvance Fecha a cuando se quiere adelantar. - * @param vWarehouseFk Almacén - */ - DECLARE vDateInventory DATE; - - SELECT inventoried INTO vDateInventory FROM config; - - CREATE OR REPLACE TEMPORARY TABLE tStock - (itemFk INT PRIMARY KEY, amount INT) - ENGINE = MEMORY; - - INSERT INTO tStock(itemFk, amount) - SELECT itemFk, SUM(quantity) amount FROM - ( - SELECT itemFk, quantity - FROM itemTicketOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryIn - WHERE landed >= vDateInventory - AND landed < vDateFuture - AND isVirtualStock = FALSE - AND warehouseInFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseOutFk = vWarehouseFk - ) t - GROUP BY itemFk HAVING amount != 0; - - CREATE OR REPLACE TEMPORARY TABLE tmp.filter - (INDEX (id)) - SELECT dest.*, - origin.* - FROM ( - SELECT s.ticketFk futureId, - t.workerFk, - t.shipped futureShipped, - t.totalWithVat futureTotalWithVat, - st.name futureState, - t.addressFk futureAddressFk, - am.name futureAgency, - count(s.id) futureLines, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, - CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM((s.quantity <= IFNULL(tst.amount,0))) hasStock, - st.classColor futureClassColor, - ( - count(s.id) - - SUM((s.quantity <= IFNULL(tst.amount,0))) - ) notMovableLines, - ( - count(s.id) = - SUM((s.quantity <= IFNULL(tst.amount,0))) - ) isFullMovable - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN saleVolume sv ON sv.saleFk = s.id - JOIN item i ON i.id = s.itemFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN `state` st ON st.id = ts.stateFk - JOIN agencyMode am ON t.agencyModeFk = am.id - LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tStock tst ON tst.itemFk = i.id - WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) - AND t.warehouseFk = vWarehouseFk - GROUP BY t.id - ) origin - JOIN ( - SELECT t.id, - t.addressFk, - st.name state, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, - t.shipped, - t.totalWithVat, - am.name agency, - CAST(SUM(litros) AS DECIMAL(10,0)) liters, - CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, - st.classColor, - IF(HOUR(t.shipped), - HOUR(t.shipped), - COALESCE(HOUR(zc.hour),HOUR(z.hour)) - ) preparation - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN saleVolume sv ON sv.saleFk = s.id - JOIN item i ON i.id = s.itemFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN `state` st ON st.id = ts.stateFk - JOIN agencyMode am ON t.agencyModeFk = am.id - JOIN ticketCanAdvanceConfig - LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN `zone` z ON z.id = t.zoneFk - LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk - WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) - AND t.warehouseFk = vWarehouseFk - AND st.order <= destinationOrder - GROUP BY t.id - ) dest ON dest.addressFk = origin.futureAddressFk - WHERE origin.hasStock != 0; - - DROP TEMPORARY TABLE tStock; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index 44149126a..58b09e404 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -1,5 +1,7 @@ + + DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN /** * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. @@ -8,91 +10,79 @@ BEGIN * @param vDateToAdvance Fecha a cuando se quiere adelantar. * @param vWarehouseFk Almacén */ + DECLARE vDateInventory DATE; - CALL item_getStock(vWarehouseFk, vDateToAdvance, NULL); - CALL item_getMinacum( - vWarehouseFk, - vDateToAdvance, - DATEDIFF(DATE_SUB(vDateFuture, INTERVAL 1 DAY), vDateToAdvance), - NULL - ); + SELECT inventoried INTO vDateInventory FROM config; + + CREATE OR REPLACE TEMPORARY TABLE tStock + (itemFk INT PRIMARY KEY, amount INT) + ENGINE = MEMORY; + + INSERT INTO tStock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) - SELECT - origin.ticketFk futureId, - dest.ticketFk id, - dest.state, - origin.futureState, - origin.futureIpt, - dest.ipt, - origin.workerFk, - origin.futureLiters, - origin.futureLines, - dest.shipped, - origin.shipped futureShipped, - dest.totalWithVat, - origin.totalWithVat futureTotalWithVat, - dest.agency, - dest.agencyModeFk, - origin.futureAgency, - origin.agencyModeFk futureAgencyModeFk, - dest.lines, - dest.liters, - origin.futureLines - origin.hasStock AS notMovableLines, - (origin.futureLines = origin.hasStock) AS isFullMovable, - dest.zoneFk, - origin.futureZoneFk, - origin.futureZoneName, - origin.classColor futureClassColor, - dest.classColor, - origin.clientFk futureClientFk, - origin.addressFk futureAddressFk, - origin.warehouseFk futureWarehouseFk, - origin.companyFk futureCompanyFk, - IFNULL(dest.nickname, origin.nickname) nickname, - dest.landed + SELECT dest.*, + origin.* FROM ( - SELECT - s.ticketFk, - c.salesPersonFk workerFk, - t.shipped, - t.totalWithVat, - st.name futureState, - am.name futureAgency, - count(s.id) futureLines, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, - CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, - z.id futureZoneFk, - z.name futureZoneName, - st.classColor, - t.clientFk, - t.nickname, + SELECT s.ticketFk futureId, + t.workerFk, + t.shipped futureShipped, + t.totalWithVat futureTotalWithVat, + st.name futureState, + t.addressFk futureAddressFk, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM((s.quantity <= IFNULL(tst.amount,0))) hasStock, + st.classColor futureClassColor, + ( + count(s.id) - + SUM((s.quantity <= IFNULL(tst.amount,0))) + ) notMovableLines, + ( + count(s.id) = + SUM((s.quantity <= IFNULL(tst.amount,0))) + ) isFullMovable + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tStock tst ON tst.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) origin + JOIN ( + SELECT t.id, t.addressFk, - t.warehouseFk, - t.companyFk, - t.agencyModeFk - FROM ticket t - JOIN client c ON c.id = t.clientFk - JOIN sale s ON s.ticketFk = t.id - JOIN saleVolume sv ON sv.saleFk = s.id - JOIN item i ON i.id = s.itemFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state st ON st.id = ts.stateFk - JOIN agencyMode am ON t.agencyModeFk = am.id - JOIN zone z ON t.zoneFk = z.id - LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id - AND im.warehouseFk = vWarehouseFk - LEFT JOIN tmp.itemList il ON il.itemFk = i.id - WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) - AND t.warehouseFk = vWarehouseFk - GROUP BY t.id - ) origin - LEFT JOIN ( - SELECT - t.id ticketFk, st.name state, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t.shipped, @@ -101,31 +91,32 @@ BEGIN CAST(SUM(litros) AS DECIMAL(10,0)) liters, CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, st.classColor, - t.clientFk, - t.nickname, - t.addressFk, - t.zoneFk, - t.warehouseFk, - t.companyFk, - t.landed, - t.agencyModeFk + CONCAT_WS(':', + IF(HOUR(t.shipped), + HOUR(t.shipped), + COALESCE(HOUR(zc.hour),HOUR(z.hour))), + IF(MINUTE(t.shipped), + MINUTE(t.shipped), + COALESCE(MINUTE(zc.hour),MINUTE(z.hour))) + ) preparation FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state st ON st.id = ts.stateFk + JOIN `state` st ON st.id = ts.stateFk JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN ticketCanAdvanceConfig LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t.warehouseFk = vWarehouseFk - AND st.order <= 5 + AND st.order <= destinationOrder GROUP BY t.id - ) dest ON dest.addressFk = origin.addressFk - WHERE origin.hasStock; + ) dest ON dest.addressFk = origin.futureAddressFk + WHERE origin.hasStock != 0; - DROP TEMPORARY TABLE IF EXISTS - tmp.itemList, - tmp.itemMinacum; + DROP TEMPORARY TABLE tStock; END$$ DELIMITER ; diff --git a/db/versions/11221-chocolateSalal/00-firstScript.sql b/db/versions/11221-chocolateSalal/00-firstScript.sql new file mode 100644 index 000000000..8dba40cb3 --- /dev/null +++ b/db/versions/11221-chocolateSalal/00-firstScript.sql @@ -0,0 +1,12 @@ +-- Place your SQL code here +CREATE TABLE IF NOT EXISTS `vn`.`ticketCanAdvanceConfig` ( + `id` INT auto_increment NULL, + `destinationOrder` INT NULL, + CONSTRAINT `ticketCanAdvanceConfig_PK` PRIMARY KEY (id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `vn`.`ticketCanAdvanceConfig` + SET `destinationOrder` = 5; From 88a8b4975bd9118f1c7a306b964a69f7c731ef5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 9 Sep 2024 12:37:49 +0200 Subject: [PATCH 081/137] fix: ticket 218504 ticket_close --- db/routines/vn/procedures/ticket_close.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_close.sql b/db/routines/vn/procedures/ticket_close.sql index f8bbe239b..639b6b505 100644 --- a/db/routines/vn/procedures/ticket_close.sql +++ b/db/routines/vn/procedures/ticket_close.sql @@ -85,7 +85,7 @@ BEGIN IF(vHasDailyInvoice) AND vHasToInvoice THEN SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial; - IF NOT vSerial THEN + IF vSerial IS NULL THEN CALL util.throw('Cannot booking without a serial'); END IF; From d9a4b3e6fb7b689a644499ca205b3e3c54c57226 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 12:42:19 +0200 Subject: [PATCH 082/137] fix: refs #7346 Global invoice --- modules/invoiceOut/front/global-invoicing/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/invoiceOut/front/global-invoicing/index.js b/modules/invoiceOut/front/global-invoicing/index.js index 9a936611a..b9a5ffe91 100644 --- a/modules/invoiceOut/front/global-invoicing/index.js +++ b/modules/invoiceOut/front/global-invoicing/index.js @@ -105,7 +105,8 @@ class Controller extends Section { addressId: address.id, invoiceDate: this.invoiceDate, maxShipped: this.maxShipped, - companyFk: this.companyFk + companyFk: this.companyFk, + serialType: 'quick' }; this.$http.post(`InvoiceOuts/invoiceClient`, params) From f15b33778cd337fd850732697aae9fd14482ec32 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 14:21:42 +0200 Subject: [PATCH 083/137] feat(salix): refs #5938 #5938 replace variables --- e2e/helpers/selectors.js | 2 +- e2e/paths/05-ticket/21_future.spec.js | 4 +- .../back/methods/ticket/getTicketsFuture.js | 12 ++--- .../ticket/specs/getTicketsFuture.spec.js | 48 +++++++++---------- .../front/future-search-panel/index.html | 8 ++-- modules/ticket/front/future/index.js | 4 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 097c6e1ab..cfc641a5d 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -688,7 +688,7 @@ export default { searchResult: 'vn-ticket-future tbody tr', openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', originDated: 'vn-date-picker[label="Origin date"]', - futureDated: 'vn-date-picker[label="Destination date"]', + futureScopeDays: 'vn-date-picker[label="Destination date"]', linesMax: 'vn-textfield[label="Max Lines"]', litersMax: 'vn-textfield[label="Max Liters"]', ipt: 'vn-autocomplete[label="Origin IPT"]', diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 7b7d478f7..294d79cda 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -30,11 +30,11 @@ describe('Ticket Future path', () => { expect(message.text).toContain('warehouseFk is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.futureDated); + await page.clearInput(selectors.ticketFuture.futureScopeDays); await page.waitToClick(selectors.ticketFuture.submit); message = await page.waitForSnackbar(); - expect(message.text).toContain('futureDated is a required argument'); + expect(message.text).toContain('futureScopeDays is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.originDated); diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index abd269e5e..247924591 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -9,13 +9,13 @@ module.exports = Self => { accessType: 'READ', accepts: [ { - arg: 'originDated', + arg: 'originScopeDays', type: 'date', description: 'The date in question', required: true }, { - arg: 'futureDated', + arg: 'futureScopeDays', type: 'date', description: 'The date to probe', required: true @@ -129,9 +129,9 @@ module.exports = Self => { ] }; case 'state': - return {'f.stateCode': {like: `%${value}%`}}; + return {'f.alertLevel': value}; case 'futureState': - return {'f.futureStateCode': {like: `%${value}%`}}; + return {'f.futureAlertLevel': value}; } }); @@ -141,7 +141,7 @@ module.exports = Self => { stmt = new ParameterizedSQL( `CALL vn.ticket_canbePostponed(?,?,?)`, - [args.originDated, args.futureDated, args.warehouseFk]); + [args.originScopeDays, args.futureScopeDays, args.warehouseFk]); stmts.push(stmt); @@ -170,7 +170,7 @@ module.exports = Self => { LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id `); - if (args.problems != undefined && (!args.originDated && !args.futureDated)) + if (args.problems != undefined && (!args.originScopeDays && !args.futureScopeDays)) throw new UserError('Choose a date range or days forward'); let condition; diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js index 4b28f34ea..e1e9a0ed2 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js @@ -12,8 +12,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, }; @@ -35,8 +35,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: true }; @@ -60,8 +60,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: false }; @@ -85,8 +85,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: null }; @@ -110,8 +110,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, state: 'OK' }; @@ -135,8 +135,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureState: 'OK' }; @@ -160,8 +160,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, ipt: null }; @@ -185,8 +185,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, ipt: 'H' }; @@ -210,8 +210,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureIpt: null }; @@ -235,8 +235,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureIpt: 'H' }; @@ -260,8 +260,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, id: 13 }; @@ -285,8 +285,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureId: 12 }; diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index d873fbc37..d74a0f2a0 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -1,7 +1,7 @@
@@ -9,13 +9,13 @@ diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index f18dfa17e..a7d579681 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -65,8 +65,8 @@ export default class Controller extends Section { this.$http.get(`UserConfigs/getUserConfig`) .then(res => { this.filterParams = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: res.data.warehouseFk }; this.$.model.applyFilter(null, this.filterParams); From 89c2d2705c7dfed5be92f4f5409e3873f07b7e27 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 14:21:59 +0200 Subject: [PATCH 084/137] feat(salix): refs #5938 #5938 change value-field --- modules/ticket/front/future-search-panel/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index d74a0f2a0..bcf6e5fe3 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -59,7 +59,7 @@ @@ -69,7 +69,7 @@ From 52f368e4f7d96d91598ec0917f796915d86336c7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 14:25:13 +0200 Subject: [PATCH 085/137] fix: refs #7346 Global invoice --- modules/invoiceOut/front/global-invoicing/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/invoiceOut/front/global-invoicing/index.js b/modules/invoiceOut/front/global-invoicing/index.js index b9a5ffe91..5ea8c2c28 100644 --- a/modules/invoiceOut/front/global-invoicing/index.js +++ b/modules/invoiceOut/front/global-invoicing/index.js @@ -106,7 +106,7 @@ class Controller extends Section { invoiceDate: this.invoiceDate, maxShipped: this.maxShipped, companyFk: this.companyFk, - serialType: 'quick' + serialType: 'global' }; this.$http.post(`InvoiceOuts/invoiceClient`, params) From bf1a43a23ec43d1a129e2b02ef03f301cd1ecd71 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 14:43:16 +0200 Subject: [PATCH 086/137] refactor: refs #7900 Deleted sectorProdPriority column --- db/routines/vn/procedures/productionSectorList.sql | 1 - db/routines/vn/views/itemShelvingAvailable.sql | 1 - db/routines/vn2008/views/state.sql | 1 - db/versions/11222-azureCordyline/00-firstScript.sql | 1 + 4 files changed, 1 insertion(+), 3 deletions(-) create mode 100644 db/versions/11222-azureCordyline/00-firstScript.sql diff --git a/db/routines/vn/procedures/productionSectorList.sql b/db/routines/vn/procedures/productionSectorList.sql index f61ec7ec9..ed6eff147 100644 --- a/db/routines/vn/procedures/productionSectorList.sql +++ b/db/routines/vn/procedures/productionSectorList.sql @@ -55,7 +55,6 @@ BEGIN i.itemPackingTypeFk, isa.`size`, isa.Estado, - isa.sectorProdPriority, isa.available, isa.sectorFk, isa.matricula, diff --git a/db/routines/vn/views/itemShelvingAvailable.sql b/db/routines/vn/views/itemShelvingAvailable.sql index 561569285..15083e6cc 100644 --- a/db/routines/vn/views/itemShelvingAvailable.sql +++ b/db/routines/vn/views/itemShelvingAvailable.sql @@ -10,7 +10,6 @@ AS SELECT `s`.`id` AS `saleFk`, `s`.`concept` AS `concept`, `i`.`size` AS `size`, `st`.`name` AS `Estado`, - `st`.`sectorProdPriority` AS `sectorProdPriority`, `stock`.`visible` AS `available`, `stock`.`sectorFk` AS `sectorFk`, `stock`.`shelvingFk` AS `matricula`, diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql index 63f6589af..9f7fcccd8 100644 --- a/db/routines/vn2008/views/state.sql +++ b/db/routines/vn2008/views/state.sql @@ -6,7 +6,6 @@ AS SELECT `s`.`id` AS `id`, `s`.`order` AS `order`, `s`.`alertLevel` AS `alert_level`, `s`.`code` AS `code`, - `s`.`sectorProdPriority` AS `sectorProdPriority`, `s`.`nextStateFk` AS `nextStateFk`, `s`.`isPreviousPreparable` AS `isPreviousPreparable`, `s`.`isPicked` AS `isPicked` diff --git a/db/versions/11222-azureCordyline/00-firstScript.sql b/db/versions/11222-azureCordyline/00-firstScript.sql new file mode 100644 index 000000000..c63228911 --- /dev/null +++ b/db/versions/11222-azureCordyline/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.state DROP COLUMN sectorProdPriority; From a5f6fe95ea5b874504142ce4cb9d48b278f1ec80 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 14:58:02 +0200 Subject: [PATCH 087/137] feat(salix): refs #5938 #5938 add futureAlertLevel --- db/routines/vn/procedures/ticket_canbePostponed.sql | 2 ++ e2e/helpers/selectors.js | 2 +- e2e/paths/05-ticket/21_future.spec.js | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canbePostponed.sql b/db/routines/vn/procedures/ticket_canbePostponed.sql index 871cafddc..1f3c43057 100644 --- a/db/routines/vn/procedures/ticket_canbePostponed.sql +++ b/db/routines/vn/procedures/ticket_canbePostponed.sql @@ -21,6 +21,7 @@ BEGIN t.clientFk, t.warehouseFk, ts.alertLevel, + sub2.alertLevel futureAlertLevel, t.shipped, t.totalWithVat, sub2.shipped futureShipped, @@ -47,6 +48,7 @@ BEGIN t.addressFk, t.id, t.shipped, + ts.alertLevel, st.name state, st.code, st.classColor, diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index cfc641a5d..0a3892c86 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -687,7 +687,7 @@ export default { ticketFuture: { searchResult: 'vn-ticket-future tbody tr', openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', - originDated: 'vn-date-picker[label="Origin date"]', + originScopeDays: 'vn-date-picker[label="Origin date"]', futureScopeDays: 'vn-date-picker[label="Destination date"]', linesMax: 'vn-textfield[label="Max Lines"]', litersMax: 'vn-textfield[label="Max Liters"]', diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 294d79cda..60bb9c38d 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -37,11 +37,11 @@ describe('Ticket Future path', () => { expect(message.text).toContain('futureScopeDays is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.originDated); + await page.clearInput(selectors.ticketFuture.originScopeDays); await page.waitToClick(selectors.ticketFuture.submit); message = await page.waitForSnackbar(); - expect(message.text).toContain('originDated is a required argument'); + expect(message.text).toContain('originScopeDays is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.waitToClick(selectors.ticketFuture.submit); @@ -71,7 +71,7 @@ describe('Ticket Future path', () => { await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); await page.waitToClick(selectors.ticketFuture.submit); - expect(httpRequest).toContain('state=FREE'); + expect(httpRequest).toContain('state=0'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); @@ -80,7 +80,7 @@ describe('Ticket Future path', () => { await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); await page.waitToClick(selectors.ticketFuture.submit); - expect(httpRequest).toContain('futureState=FREE'); + expect(httpRequest).toContain('futureState=0'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.state); From 1aa888b1a30f20adac3372a9428281710be8d113 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 9 Sep 2024 15:11:09 +0200 Subject: [PATCH 088/137] feat(WorkerDms_filter): refs #7182 split code. fix: filter --- .../back/methods/worker-dms/docuwareFilter.js | 74 +++++++++++++++ .../worker/back/methods/worker-dms/filter.js | 90 ++++++------------- 2 files changed, 99 insertions(+), 65 deletions(-) create mode 100644 modules/worker/back/methods/worker-dms/docuwareFilter.js diff --git a/modules/worker/back/methods/worker-dms/docuwareFilter.js b/modules/worker/back/methods/worker-dms/docuwareFilter.js new file mode 100644 index 000000000..0311153b0 --- /dev/null +++ b/modules/worker/back/methods/worker-dms/docuwareFilter.js @@ -0,0 +1,74 @@ +module.exports = Self => { + Self.remoteMethodCtx('filter', { + description: 'Find docuware documents', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + description: 'The worker id', + http: {source: 'path'} + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/:id/filter`, + verb: 'GET' + } + }); + + Self.filter = async(ctx, id) => { + const models = Self.app.models; + + const {dmsTypeFk} = await models.Docuware.findOne({ + fields: ['dmsTypeFk'], + where: {code: 'hr', action: 'find'} + }); + + if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return []; + + let workerDocuware = []; + const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); + const docuwareParse = { + 'Filename': 'dmsFk', + 'Tipo Documento': 'description', + 'Stored on': 'created', + 'Document ID': 'id', + 'URL': 'download', + 'Stored by': 'name', + 'Estado': 'state' + }; + + workerDocuware = + await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; + const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; + for (document of workerDocuware) { + const docuwareId = document.id; + const defaultData = { + id: docuwareId, + workerFk: id, + dmsFk: docuwareId, + dms: { + id: docuwareId, + file: docuwareId + '.pdf', + isDocuware: true, + hasFile: false, + reference: worker.fi, + dmsFk: docuwareId, + url, + description: document.description + ' - ' + document.state, + download: document.download, + created: document.created, + dmsType: {name: 'Docuware'}, + worker: {id: null, user: {name: document.name}}, + } + }; + Object.assign(document, defaultData); + } + }; + + return workerDocuware; +}; diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index b7802a689..b92ba139b 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -8,19 +8,19 @@ module.exports = Self => { accepts: [ { arg: 'id', - type: 'Number', + type: 'number', description: 'The worker id', http: {source: 'path'} }, { arg: 'filter', - type: 'Object', + type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { @@ -36,6 +36,7 @@ module.exports = Self => { // Get ids alloweds const account = await models.VnUser.findById(userId); + const stmt = new ParameterizedSQL( `SELECT d.id, d.id dmsFk FROM workerDocument wd @@ -44,68 +45,27 @@ module.exports = Self => { LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk AND rr.role = ? `, [account.roleFk] ); - const yourOwnDms = {and: [{isReadableByWorker: true}, {worker: userId}]}; - const where = { - or: [yourOwnDms, { - role: { - neq: null - } - }] - }; - stmt.merge(conn.makeSuffix(mergeWhere(filter.where, where))); - - // Get workerDms alloweds - const dmsIds = await conn.executeStmt(stmt); - const allowedIds = dmsIds.map(dms => dms.id); - const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}, workerFk: id}}); - let workerDms = await models.WorkerDms.find(allowedFilter); - - // Get docuware info - const docuware = await models.Docuware.findOne({ - fields: ['dmsTypeFk'], - where: {code: 'hr', action: 'find'} - }); - const docuwareDmsType = docuware.dmsTypeFk; - let workerDocuware = []; - if (!filter.skip && (!docuwareDmsType || (docuwareDmsType && await models.DmsType.hasReadRole(ctx, docuwareDmsType)))) { - const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); - const docuwareParse = { - 'Filename': 'dmsFk', - 'Tipo Documento': 'description', - 'Stored on': 'created', - 'Document ID': 'id', - 'URL': 'download', - 'Stored by': 'name', - 'Estado': 'state' - }; - - workerDocuware = - await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; - const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; - for (document of workerDocuware) { - const docuwareId = document.id; - const defaultData = { - id: docuwareId, - workerFk: id, - dmsFk: docuwareId, - dms: { - id: docuwareId, - file: docuwareId + '.pdf', - isDocuware: true, - hasFile: false, - reference: worker.fi, - dmsFk: docuwareId, - url, - description: document.description + ' - ' + document.state, - download: document.download, - created: document.created, - dmsType: {name: 'Docuware'}, - worker: {id: null, user: {name: document.name}}, + const yourOwnDms = { + or: [ + {and: [ + {isReadableByWorker: true}, + {worker: userId} + ]}, + { + role: { + neq: null } - }; - Object.assign(document, defaultData); - } - } - return workerDms.concat(workerDocuware); + }] + }; + const where = mergeWhere(filter.where, yourOwnDms); + stmt.merge(conn.makeSuffix({where})); + const dmsIds = await conn.executeStmt(stmt); + + const allowedIds = dmsIds.map(dms => dms.id); + const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}}}); + + const find = await models.WorkerDms.find(allowedFilter); + + return find; }; }; From 773933ca3c32bec8745457afd9e23fb80d96c0fe Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:11:55 +0200 Subject: [PATCH 089/137] feat(salix): refs #6156 #6156 change config sql --- db/versions/11221-chocolateSalal/00-firstScript.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/versions/11221-chocolateSalal/00-firstScript.sql b/db/versions/11221-chocolateSalal/00-firstScript.sql index 8dba40cb3..680f0ee0e 100644 --- a/db/versions/11221-chocolateSalal/00-firstScript.sql +++ b/db/versions/11221-chocolateSalal/00-firstScript.sql @@ -1,12 +1,12 @@ -- Place your SQL code here -CREATE TABLE IF NOT EXISTS `vn`.`ticketCanAdvanceConfig` ( - `id` INT auto_increment NULL, - `destinationOrder` INT NULL, - CONSTRAINT `ticketCanAdvanceConfig_PK` PRIMARY KEY (id) +CREATE TABLE IF NOT EXISTS vn.ticketCanAdvanceConfig ( + id INT NOT NULL unsigned PRIMARY KEY, + destinationOrder INT NULL, + CONSTRAINT ticketCanAdvanceConfig_PK PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO `vn`.`ticketCanAdvanceConfig` - SET `destinationOrder` = 5; +INSERT INTO vn.ticketCanAdvanceConfig + SET destinationOrder = 5; From f70f475223313874abe7e9ea787a4f9e12667db8 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:12:44 +0200 Subject: [PATCH 090/137] feat(salix): refs #6156 #6156 change user definer --- db/routines/vn/procedures/ticket_canAdvance.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index 58b09e404..b9e27784d 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -1,7 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN /** * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. From f9a25617f0eed7ab6e5c6e0a0eba104dd2263e47 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:13:08 +0200 Subject: [PATCH 091/137] feat(salix): refs #6156 #6156 add missing values --- db/routines/vn/procedures/ticket_canAdvance.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index b9e27784d..b1f135e5f 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -45,7 +45,10 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) SELECT dest.*, - origin.* + origin.*, + IFNULL(dest.nickname, origin.nickname) nickname, + (origin.futureLines = origin.hasStock) AS isFullMovable, + origin.futureLines - origin.hasStock AS notMovableLines FROM ( SELECT s.ticketFk futureId, t.workerFk, From 615f57b2e6d5fd2951bee7f5cd9822f61af87ee5 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:13:32 +0200 Subject: [PATCH 092/137] feat(salix): refs #6156 #6156 simplify CONCAT_WS --- db/routines/vn/procedures/ticket_canAdvance.sql | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index b1f135e5f..5be8d7d7f 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -95,13 +95,9 @@ BEGIN CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, st.classColor, CONCAT_WS(':', - IF(HOUR(t.shipped), - HOUR(t.shipped), - COALESCE(HOUR(zc.hour),HOUR(z.hour))), - IF(MINUTE(t.shipped), - MINUTE(t.shipped), - COALESCE(MINUTE(zc.hour),MINUTE(z.hour))) - ) preparation + COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)), + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) + ) preparation FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id From c407dde7a021c3defe5ca8003758dbf163995159 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:14:01 +0200 Subject: [PATCH 093/137] feat(salix): refs #6156 #6156 remove redundant condition --- db/routines/vn/procedures/ticket_canAdvance.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index 5be8d7d7f..c5b918def 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -114,7 +114,7 @@ BEGIN AND st.order <= destinationOrder GROUP BY t.id ) dest ON dest.addressFk = origin.futureAddressFk - WHERE origin.hasStock != 0; + WHERE origin.hasStock; DROP TEMPORARY TABLE tStock; END$$ From 45649359be0b2c788d93f1847a9c9b18159cad1d Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 9 Sep 2024 15:59:17 +0200 Subject: [PATCH 094/137] chore: refs #4074 fix test --- .../02-client/04_edit_billing_data.spec.js | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/e2e/paths/02-client/04_edit_billing_data.spec.js b/e2e/paths/02-client/04_edit_billing_data.spec.js index 10eb85406..12a2e7b74 100644 --- a/e2e/paths/02-client/04_edit_billing_data.spec.js +++ b/e2e/paths/02-client/04_edit_billing_data.spec.js @@ -18,7 +18,7 @@ const $ = { watcher: 'vn-client-billing-data vn-watcher' }; -describe('Client Edit billing data path', () => { +fdescribe('Client Edit billing data path', () => { let browser; let page; beforeAll(async() => { @@ -35,6 +35,14 @@ describe('Client Edit billing data path', () => { it(`should attempt to edit the billing data without an IBAN but fail`, async() => { await page.autocompleteSearch($.payMethod, 'PayMethod with IBAN'); + await page.waitToClick($.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('That payment method requires an IBAN'); + }); + + it(`should edit the billing data and save the form`, async() => { + await page.autocompleteSearch($.payMethod, 'PayMethod five'); await page.autocompleteSearch($.swiftBic, 'BBKKESMMMMM'); await page.clearInput($.dueDay); await page.write($.dueDay, '60'); @@ -45,10 +53,13 @@ describe('Client Edit billing data path', () => { await page.waitToClick($.saveButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('That payment method requires an IBAN'); + expect(message.text).toContain('Notification sent!'); }); it(`should create a new BIC code`, async() => { + await page.loginAndModule('financial', 'client'); + await page.accessToSearchResult('Bruce Banner'); + await page.accessToSection('client.card.billingData'); await page.waitToClick($.newBankEntityButton); await page.write($.newBankEntityName, 'Gotham City Bank'); await page.write($.newBankEntityBIC, 'GTHMCT'); @@ -66,7 +77,7 @@ describe('Client Edit billing data path', () => { it(`should confirm the IBAN pay method was sucessfully saved`, async() => { const payMethod = await page.waitToGetProperty($.payMethod, 'value'); - expect(payMethod).toEqual('PayMethod with IBAN'); + expect(payMethod).toEqual('PayMethod five'); }); it(`should clear the BIC code field, update the IBAN to see how he BIC code autocompletes`, async() => { @@ -79,14 +90,6 @@ describe('Client Edit billing data path', () => { expect(automaticCode).toEqual('CAIXESBB'); }); - it(`should save the form with all its new data`, async() => { - await page.waitForWatcherData($.watcher); - await page.waitToClick($.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Notification sent!'); - }); - it('should confirm the billing data have been edited', async() => { const dueDate = await page.waitToGetProperty($.dueDay, 'value'); const IBAN = await page.waitToGetProperty($.IBAN, 'value'); @@ -94,7 +97,9 @@ describe('Client Edit billing data path', () => { const receivedCoreLCR = await page.checkboxState($.receivedCoreLCRCheckbox); const receivedCoreVNL = await page.checkboxState($.receivedCoreVNLCheckbox); const receivedB2BVNL = await page.checkboxState($.receivedB2BVNLCheckbox); + const payMethod = await page.waitToGetProperty($.payMethod, 'value'); + expect(payMethod).toEqual('PayMethod five'); expect(dueDate).toEqual('60'); expect(IBAN).toEqual('ES9121000418450200051332'); expect(swiftBic).toEqual('CAIXESBB'); From eadff638f90d9472f96c4a0dc061457b85cb6e86 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 9 Sep 2024 15:59:40 +0200 Subject: [PATCH 095/137] chore: refs #4074 drop focus --- e2e/paths/02-client/04_edit_billing_data.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/02-client/04_edit_billing_data.spec.js b/e2e/paths/02-client/04_edit_billing_data.spec.js index 12a2e7b74..ca2c3b953 100644 --- a/e2e/paths/02-client/04_edit_billing_data.spec.js +++ b/e2e/paths/02-client/04_edit_billing_data.spec.js @@ -18,7 +18,7 @@ const $ = { watcher: 'vn-client-billing-data vn-watcher' }; -fdescribe('Client Edit billing data path', () => { +describe('Client Edit billing data path', () => { let browser; let page; beforeAll(async() => { From 125c0c9b3b64fdc538ff8becfba50b45ac3c6675 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 10 Sep 2024 07:50:40 +0200 Subject: [PATCH 096/137] refactor: refs #6346 requested changes --- .../11088-bronzeAspidistra/00-firstScript.sql | 2 +- loopback/locale/en.json | 6 +- loopback/locale/es.json | 5 +- .../methods/wagonType/specs/wagonTray.spec.js | 58 +++++++++++++++++++ modules/wagon/back/models/wagon-type-tray.js | 7 +-- 5 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js diff --git a/db/versions/11088-bronzeAspidistra/00-firstScript.sql b/db/versions/11088-bronzeAspidistra/00-firstScript.sql index 98203c9d1..11effc5d2 100644 --- a/db/versions/11088-bronzeAspidistra/00-firstScript.sql +++ b/db/versions/11088-bronzeAspidistra/00-firstScript.sql @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS vn.wagonTypeTray; -CREATE TABLE vn.wagonTypeTray ( +CREATE OR REPLACE TABLE vn.wagonTypeTray ( id INT UNSIGNED auto_increment NULL, wagonTypeFk int(11) unsigned NULL, height INT UNSIGNED NULL, diff --git a/loopback/locale/en.json b/loopback/locale/en.json index d9d9c8511..1753d1d07 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -236,6 +236,8 @@ "Cannot send mail": "Cannot send mail", "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`", "This postcode already exists": "This postcode already exists", - "Original invoice not found": "Original invoice not found" - + "Original invoice not found": "Original invoice not found", + "There is already a tray with the same height": "There is already a tray with the same height", + "The height must be greater than 50cm": "The height must be greater than 50cm", + "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d7c2d31a0..a14262c49 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -374,7 +374,6 @@ "Original invoice not found": "Factura original no encontrada", "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe", "There is already a tray with the same height": "Ya existe una bandeja con la misma altura", - "You must define wagon and height": "Debes definir un tipo de vagón y la altura", - "The maximum height of the wagon is": "La altura máxima es %d", - "The height must be greater than": "The height must be greater than %d" + "The height must be greater than 50cm": "La altura debe ser superior a 50cm", + "The maximum height of the wagon is 200cm": "La altura máxima es 200cm" } \ No newline at end of file diff --git a/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js b/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js new file mode 100644 index 000000000..9e4ae0907 --- /dev/null +++ b/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js @@ -0,0 +1,58 @@ +const models = require('vn-loopback/server/server').models; + +fdescribe('WagonTray max height()', () => { + it(`should throw an error if the tray's height is above the maximum of the wagon`, async() => { + const tx = await models.WagonTypeTray.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.WagonTypeTray.create({height: 210, wagonTypeFk: 1, wagonTypeColorFk: 4}, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe('The maximum height of the wagon is 200cm'); + }); + + it(`should throw an error if the tray's height is already in the wagon`, async() => { + const tx = await models.WagonTypeTray.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.WagonTypeTray.create({height: 50, wagonTypeFk: 1, wagonTypeColorFk: 2}, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe('There is already a tray with the same height'); + }); + + it(`should throw an error if the tray's height is below the minimum between the trays`, async() => { + const tx = await models.WagonTypeTray.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.WagonTypeTray.create({height: 40, wagonTypeFk: 1, wagonTypeColorFk: 4}, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe('The height must be greater than 50cm'); + }); +}); + diff --git a/modules/wagon/back/models/wagon-type-tray.js b/modules/wagon/back/models/wagon-type-tray.js index 5bcb1d3c7..219f20bfb 100644 --- a/modules/wagon/back/models/wagon-type-tray.js +++ b/modules/wagon/back/models/wagon-type-tray.js @@ -15,14 +15,11 @@ module.exports = Self => { if (tray.length) throw new UserError('There is already a tray with the same height'); - if (!wagonTypeFk && !height) - throw new UserError('You must define wagon and height'); - if (height < config.minHeightBetweenTrays) - throw new UserError('The height must be greater than', 'HEIGHT_GREATER_THAN', config.minHeightBetweenTrays); + throw new UserError('The height must be greater than 50cm'); if (height > config.maxWagonHeight) - throw new UserError('The maximum height of the wagon is', 'MAX_WAGON_HEIGHT', config.maxWagonHeight); + throw new UserError('The maximum height of the wagon is 200cm'); } }); }; From 97597156091e18cdea6529f941c5fc87eb77e199 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 10 Sep 2024 07:52:09 +0200 Subject: [PATCH 097/137] fix: refs #6346 created test --- db/.pullinfo.json | 2 +- modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 27d2c7535..5b75584d1 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345" + "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e" } } } diff --git a/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js b/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js index 9e4ae0907..783c1a621 100644 --- a/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js +++ b/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('WagonTray max height()', () => { +describe('WagonTray max height()', () => { it(`should throw an error if the tray's height is above the maximum of the wagon`, async() => { const tx = await models.WagonTypeTray.beginTransaction({}); From e74da7cbaba7cf08c025fe08b4cc79f2c236a9b4 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 10 Sep 2024 08:17:47 +0200 Subject: [PATCH 098/137] feat: refs #7953 pullinfo --- db/.pullinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 27d2c7535..5b75584d1 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345" + "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e" } } } From 1c0e148233f066993713b92355fc4b00fc52c7f0 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 10 Sep 2024 09:08:43 +0200 Subject: [PATCH 099/137] fix: cau #217599 --- modules/client/back/models/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 0a8ebcae5..dc19c5d81 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -320,7 +320,8 @@ module.exports = Self => { // Credit management changes - if (changes?.rating >= 0 || changes?.recommendedCredit >= 0) + if ((changes?.rating != null && changes.rating >= 0) + || (changes?.recommendedCredit != null && changes.recommendedCredit >= 0)) await Self.changeCreditManagement(ctx, finalState, changes); const oldInstance = {}; From 91abf2eefe7a68473b19fbf16794200fe37a03ea Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 09:50:02 +0200 Subject: [PATCH 100/137] refactor: refs #7663 accurate error --- loopback/locale/es.json | 3 ++- modules/ticket/back/methods/ticket/setWeight.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e9e9cd212..064ea4a95 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -373,5 +373,6 @@ "Too many records": "Demasiados registros", "Original invoice not found": "Factura original no encontrada", "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe", - "Weight already set": "El peso ya está establecido" + "Weight already set": "El peso ya está establecido", + "This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index 47087d384..b3b505832 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -59,7 +59,7 @@ module.exports = Self => { workerDepartments.length == 2 && workerDepartments[0].departmentFk != workerDepartments[1].departmentFk ) - throw new UserError('You don\'t have enough privileges'); + throw new UserError('This ticket is not allocated to your department'); } await ticket.updateAttribute('weight', weight, myOptions); From bb27f0f1f531b958f49910b83a3559d60022c82b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 10 Sep 2024 10:34:28 +0200 Subject: [PATCH 101/137] build: init version 2440 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bbb83c4b0..1d3b9d253 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.36.0", + "version": "24.40.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 01d591af53d5b00eed6e35f3537f9eb423df318f Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 10 Sep 2024 12:58:16 +0200 Subject: [PATCH 102/137] fix: refs #7564 Deleted query --- db/versions/11124-greenBamboo/01-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/versions/11124-greenBamboo/01-firstScript.sql b/db/versions/11124-greenBamboo/01-firstScript.sql index 9cacbd5ff..af3a40f14 100644 --- a/db/versions/11124-greenBamboo/01-firstScript.sql +++ b/db/versions/11124-greenBamboo/01-firstScript.sql @@ -1,4 +1,5 @@ -- Calculamos todos los volumenes de todos los tickets una sola vez +/* Se ejecutará el dia de test - master manualmente para no hacer lenta la subida CREATE OR REPLACE TEMPORARY TABLE tmp.tTicketVolume (PRIMARY KEY (id)) ENGINE = MEMORY @@ -14,3 +15,4 @@ UPDATE vn.ticket t SET t.volume = tv.volume; DROP TEMPORARY TABLE tmp.tTicketVolume; +*/ From 0bbf10ca4f7d928cb3754889b1d289c67fe902d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 10 Sep 2024 12:59:07 +0200 Subject: [PATCH 103/137] fix: refs #7213 change rounding problems --- .../vn/procedures/sale_getProblems.sql | 24 ++++-- .../vn/procedures/sale_setProblemRounding.sql | 37 --------- .../sale_setProblemRoundingByBuy.sql | 75 ------------------- .../procedures/ticket_setProblemRounding.sql | 37 --------- 4 files changed, 19 insertions(+), 154 deletions(-) delete mode 100644 db/routines/vn/procedures/sale_setProblemRounding.sql delete mode 100644 db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql delete mode 100644 db/routines/vn/procedures/ticket_setProblemRounding.sql diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 7c5204e0d..352f7de4f 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -51,7 +51,6 @@ BEGIN hasTicketRequest, isTaxDataChecked, hasComponentLack, - hasRounding, isTooLittle) SELECT sgp.ticketFk, s.id, @@ -62,10 +61,6 @@ BEGIN IF(FIND_IN_SET('hasTicketRequest', t.problem), TRUE, FALSE) hasTicketRequest, IF(FIND_IN_SET('isTaxDataChecked', t.problem), FALSE, TRUE) isTaxDataChecked, IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, - IF(FIND_IN_SET('hasRounding', s.problem), - LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250), - NULL - ) hasRounding, IF(FIND_IN_SET('isTooLittle', t.problem) AND util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE, TRUE, FALSE) isTooLittle @@ -208,6 +203,25 @@ BEGIN GROUP BY sgp.ticketFk ) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; + + CALL buyUltimate(vWarehouseFk, vDate); + INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) + SELECT ticketFk, problem ,saleFk + FROM ( + SELECT tl.ticketFk, + s.id saleFk, + LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem + FROM tmp.ticket_list tl + JOIN ticket t ON t.id = tl.ticketFk + AND t.warehouseFk = vWarehouseFk + JOIN sale s ON s.ticketFk = tl.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk + JOIN buy b ON b.id = bu.buyFk + WHERE MOD(s.quantity, b.`grouping`) + GROUP BY tl.ticketFk + )sub + ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; END LOOP; CLOSE vCursor; diff --git a/db/routines/vn/procedures/sale_setProblemRounding.sql b/db/routines/vn/procedures/sale_setProblemRounding.sql deleted file mode 100644 index 894749c7b..000000000 --- a/db/routines/vn/procedures/sale_setProblemRounding.sql +++ /dev/null @@ -1,37 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRounding`( - vSelf INT -) -BEGIN -/** - * Update the rounding problem for a sales line - * @param vSelf Id sale - */ - DECLARE vItemFk INT; - DECLARE vWarehouseFk INT; - DECLARE vShipped DATE; - DECLARE vQuantity INT; - DECLARE vIsProblemCalcNeeded BOOL; - - SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity, ticket_isProblemCalcNeeded(t.id) - INTO vItemFk, vWarehouseFk, vShipped, vQuantity, vIsProblemCalcNeeded - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE s.id = vSelf; - - CALL buy_getUltimate(vItemFk, vWarehouseFk, vShipped); - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - SELECT vSelf saleFk, - MOD(vQuantity, b.`grouping`) hasProblem, - vIsProblemCalcNeeded isProblemCalcNeeded - FROM tmp.buyUltimate bu - JOIN buy b ON b.id = bu.buyFk - WHERE bu.itemFk = vItemFk; - - CALL sale_setProblem('hasRounding'); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.buyUltimate; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql deleted file mode 100644 index b0e286d25..000000000 --- a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql +++ /dev/null @@ -1,75 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRoundingByBuy`( - vBuyFk INT -) -BEGIN -/** - * Update rounding problem for all sales related to a buy. - * - * @param vBuyFk Buy id - */ - DECLARE vItemFk INT; - DECLARE vWarehouseFk INT; - DECLARE vMaxDated DATE; - DECLARE vMinDated DATE; - DECLARE vLanding DATE; - DECLARE vLastBuy INT; - DECLARE vCurrentBuy INT; - DECLARE vGrouping INT; - - SELECT b.itemFk, t.warehouseInFk - INTO vItemFk, vWarehouseFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE b.id = vBuyFk; - - IF vItemFk AND vWarehouseFk THEN - SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped)) - INTO vMaxDated, vMinDated - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE t.shipped >= util.VN_CURDATE() - AND s.itemFk = vItemFk - AND s.quantity > 0; - - CALL buy_getUltimate(vItemFk, vWarehouseFk, vMinDated); - - SELECT bu.buyFk, b.grouping INTO vLastBuy, vGrouping - FROM tmp.buyUltimate bu - JOIN buy b ON b.id = bu.buyFk; - - DROP TEMPORARY TABLE tmp.buyUltimate; - - SET vLanding = vMaxDated; - - WHILE vCurrentBuy <> vLastBuy OR vLanding > vMinDated DO - SET vMaxDated = vLanding - INTERVAL 1 DAY; - - CALL buy_getUltimate(vItemFk, vWarehouseFk, vMaxDated); - - SELECT buyFk, landing - INTO vCurrentBuy, vLanding - FROM tmp.buyUltimate; - - DROP TEMPORARY TABLE tmp.buyUltimate; - END WHILE; - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk, isProblemCalcNeeded)) - ENGINE = MEMORY - SELECT s.id saleFk, - MOD(s.quantity, vGrouping) hasProblem, - ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE s.itemFk = vItemFk - AND s.quantity > 0 - AND t.shipped BETWEEN vMinDated AND util.dayEnd(vMaxDated); - - CALL sale_setProblem('hasRounding'); - - DROP TEMPORARY TABLE tmp.sale; - END IF; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemRounding.sql b/db/routines/vn/procedures/ticket_setProblemRounding.sql deleted file mode 100644 index 551cf67d1..000000000 --- a/db/routines/vn/procedures/ticket_setProblemRounding.sql +++ /dev/null @@ -1,37 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRounding`( - vSelf INT -) -BEGIN -/** - * Update the rounding problem for the sales lines of a ticket - * - * @param vSelf Id de ticket - */ - DECLARE vWarehouseFk INT; - DECLARE vDated DATE; - - SELECT warehouseFk, shipped - INTO vWarehouseFk, vDated - FROM ticket - WHERE id = vSelf; - - CALL buy_getUltimate(NULL, vWarehouseFk, vDated); - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk, isProblemCalcNeeded)) - SELECT s.id saleFk , - MOD(s.quantity, b.`grouping`) hasProblem, - ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - JOIN buy b ON b.id = bu.buyFk - WHERE t.id = vSelf; - - CALL sale_setProblem('hasRounding'); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.buyUltimate; -END$$ -DELIMITER ; \ No newline at end of file From d98f0a24936e1bf9b4091f006c10926a9eaa4d0a Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 13:15:58 +0200 Subject: [PATCH 104/137] chore: refs #7524 rollback --- modules/item/back/methods/item/getBalance.js | 9 +++------ modules/item/back/methods/item/specs/getBalance.spec.js | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 1a4c7999d..c835cd56f 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -8,10 +8,6 @@ module.exports = Self => { required: true, description: 'Filter defining where and paginated data', http: {source: 'query'} - }, { - arg: 'noLimit', - type: 'Boolean', - required: false, }], returns: { type: ['Object'], @@ -20,10 +16,11 @@ module.exports = Self => { http: { path: `/getBalance`, verb: 'GET' - } + }, + noLimit: true }); - Self.getBalance = async(ctx, filter, noLimit, options) => { + Self.getBalance = async(ctx, filter, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index cef206411..95de3cc50 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -23,7 +23,7 @@ describe('item getBalance()', () => { date: null } }; - const results = await models.Item.getBalance(ctx, filter, true, options); + const results = await models.Item.getBalance(ctx, filter, options); const result = results.find(element => element.clientType == 'loses'); @@ -57,8 +57,8 @@ describe('item getBalance()', () => { } }; - const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, true, options); - const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, true, options); + const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, options); + const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options); expect(firstItemBalance[9].claimFk).toEqual(null); expect(secondItemBalance[7].claimFk).toEqual(1); From 8fd7c1a8ddd775a7871631ee1d444e7c43bc5822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 10 Sep 2024 13:16:15 +0200 Subject: [PATCH 105/137] fix: refs #7213 change rounding problems --- db/routines/vn/procedures/sale_getProblems.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 352f7de4f..40b72a878 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -208,18 +208,18 @@ BEGIN INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem ,saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, s.id saleFk, LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk AND t.warehouseFk = vWarehouseFk - JOIN sale s ON s.ticketFk = tl.ticketFk + JOIN sale s ON s.ticketFk = sgp.ticketFk JOIN item i ON i.id = s.itemFk JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN buy b ON b.id = bu.buyFk WHERE MOD(s.quantity, b.`grouping`) - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk )sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; END LOOP; From 1ff1a97f29e9638fddabb1bbaa6fc3d539d815d4 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 13:21:56 +0200 Subject: [PATCH 106/137] feat: refs #7524 check noLimit method key --- loopback/common/models/vn-model.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 269ed673d..596ec0967 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,7 +28,7 @@ module.exports = function(Self) { }); this.beforeRemote('**', async ctx => { - if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; + if (ctx.method.noLimit || !this.hasFilter(ctx)) return; const defaultLimit = this.app.orm.selectLimit; const filter = ctx.args.filter || {limit: defaultLimit}; @@ -40,7 +40,7 @@ module.exports = function(Self) { }); this.afterRemote('**', async ctx => { - if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; + if (ctx.method.noLimit || !this.hasFilter(ctx)) return; const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; @@ -352,10 +352,5 @@ module.exports = function(Self) { return ctx.req.method.toUpperCase() === 'GET' && ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); }, - - hasNoLimit(ctx) { - return ctx.method.accepts.some(x => x.arg.toLowerCase() === 'nolimit') && ctx.args.noLimit; - } - }); }; From e3b51c81f9a4bd67cffa95e7e5ced1c80971c08a Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 16:37:46 +0200 Subject: [PATCH 107/137] refactor: refs #7524 wrap it up in a fn --- loopback/common/models/vn-model.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 596ec0967..e24653d13 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,7 +28,7 @@ module.exports = function(Self) { }); this.beforeRemote('**', async ctx => { - if (ctx.method.noLimit || !this.hasFilter(ctx)) return; + if (!this.hasFilter(ctx)) return; const defaultLimit = this.app.orm.selectLimit; const filter = ctx.args.filter || {limit: defaultLimit}; @@ -40,7 +40,7 @@ module.exports = function(Self) { }); this.afterRemote('**', async ctx => { - if (ctx.method.noLimit || !this.hasFilter(ctx)) return; + if (!this.hasFilter(ctx)) return; const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; @@ -349,8 +349,10 @@ module.exports = function(Self) { }, hasFilter(ctx) { - return ctx.req.method.toUpperCase() === 'GET' && - ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); + const {method, req} = ctx; + if (method.noLimit) return false; + return req.method.toUpperCase() === 'GET' && + method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); }, }); }; From bebd49f08a84cde0acbf4a9a52362424e9293da0 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 11 Sep 2024 07:08:36 +0200 Subject: [PATCH 108/137] fix: debugAdd refs #6861 --- .../vn/procedures/itemShelvingSale_addBySectorCollection.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql index 26e661d9a..4f69c9a90 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql @@ -30,6 +30,8 @@ BEGIN FROM operator WHERE workerFk = account.myUser_getId(); + CALL util.debugAdd('itemShelvingSale_addBySectorCollection',CONCAT(vSectorCollectionFk,' - ', account.myUser_getId())); + OPEN vSales; l: LOOP SET vDone = FALSE; From b492a1e6a8858f39f118bc0a356b14ff5f1b7860 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 11 Sep 2024 08:05:26 +0200 Subject: [PATCH 109/137] feat: refs #6868 refs# 6868 handleUser --- db/versions/11223-turquoiseLilium/00-firstScript.sql | 2 ++ modules/account/back/models/account.json | 7 ------- 2 files changed, 2 insertions(+), 7 deletions(-) create mode 100644 db/versions/11223-turquoiseLilium/00-firstScript.sql diff --git a/db/versions/11223-turquoiseLilium/00-firstScript.sql b/db/versions/11223-turquoiseLilium/00-firstScript.sql new file mode 100644 index 000000000..9003451c4 --- /dev/null +++ b/db/versions/11223-turquoiseLilium/00-firstScript.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES( 'Device', 'handleUser', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/account/back/models/account.json b/modules/account/back/models/account.json index 466b2bc04..fc1bbeb3d 100644 --- a/modules/account/back/models/account.json +++ b/modules/account/back/models/account.json @@ -31,13 +31,6 @@ "principalId": "$everyone", "permission": "ALLOW" }, - { - "property": "loginApp", - "accessType": "EXECUTE", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - }, { "property": "logout", "accessType": "EXECUTE", From 8dc83e244473b172cac65892ceef5b6de2183d3e Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 11 Sep 2024 08:16:21 +0200 Subject: [PATCH 110/137] feat: refs #7182 optimize workerDms filter --- .../worker/back/methods/worker-dms/filter.js | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index b92ba139b..ed0490f54 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -57,15 +57,66 @@ module.exports = Self => { } }] }; + const where = mergeWhere(filter.where, yourOwnDms); stmt.merge(conn.makeSuffix({where})); const dmsIds = await conn.executeStmt(stmt); const allowedIds = dmsIds.map(dms => dms.id); - const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}}}); + const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}, workerFk: id}}); - const find = await models.WorkerDms.find(allowedFilter); + const workerDms = await models.WorkerDms.find(allowedFilter); - return find; + const workerDocuware = filter.skip ? [] : await getDocuwareasync(ctx, id); + return workerDms.concat(workerDocuware); + + async function getDocuwareasync(ctx, id) { + const {dmsTypeFk} = await models.Docuware.findOne({ + fields: ['dmsTypeFk'], + where: {code: 'hr', action: 'find'} + }); + + if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return []; + + let workerDocuware = []; + const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); + const docuwareParse = { + 'Filename': 'dmsFk', + 'Tipo Documento': 'description', + 'Stored on': 'created', + 'Document ID': 'id', + 'URL': 'download', + 'Stored by': 'name', + 'Estado': 'state' + }; + + workerDocuware = + await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; + const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; + for (document of workerDocuware) { + const docuwareId = document.id; + const defaultData = { + id: docuwareId, + workerFk: id, + dmsFk: docuwareId, + dms: { + id: docuwareId, + file: docuwareId + '.pdf', + isDocuware: true, + hasFile: false, + reference: worker.fi, + dmsFk: docuwareId, + url, + description: document.description + ' - ' + document.state, + download: document.download, + created: document.created, + dmsType: {name: 'Docuware'}, + worker: {id: null, user: {name: document.name}}, + } + }; + Object.assign(document, defaultData); + } + return workerDocuware; + } }; }; From fbfbf21e06f044ee929820e19d79279e8dd9433f Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 11 Sep 2024 08:17:18 +0200 Subject: [PATCH 111/137] fix: refs #7182 unnesesary file --- .../back/methods/worker-dms/docuwareFilter.js | 74 ------------------- 1 file changed, 74 deletions(-) delete mode 100644 modules/worker/back/methods/worker-dms/docuwareFilter.js diff --git a/modules/worker/back/methods/worker-dms/docuwareFilter.js b/modules/worker/back/methods/worker-dms/docuwareFilter.js deleted file mode 100644 index 0311153b0..000000000 --- a/modules/worker/back/methods/worker-dms/docuwareFilter.js +++ /dev/null @@ -1,74 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('filter', { - description: 'Find docuware documents', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'number', - description: 'The worker id', - http: {source: 'path'} - } - ], - returns: { - type: ['object'], - root: true - }, - http: { - path: `/:id/filter`, - verb: 'GET' - } - }); - - Self.filter = async(ctx, id) => { - const models = Self.app.models; - - const {dmsTypeFk} = await models.Docuware.findOne({ - fields: ['dmsTypeFk'], - where: {code: 'hr', action: 'find'} - }); - - if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return []; - - let workerDocuware = []; - const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); - const docuwareParse = { - 'Filename': 'dmsFk', - 'Tipo Documento': 'description', - 'Stored on': 'created', - 'Document ID': 'id', - 'URL': 'download', - 'Stored by': 'name', - 'Estado': 'state' - }; - - workerDocuware = - await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; - const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; - for (document of workerDocuware) { - const docuwareId = document.id; - const defaultData = { - id: docuwareId, - workerFk: id, - dmsFk: docuwareId, - dms: { - id: docuwareId, - file: docuwareId + '.pdf', - isDocuware: true, - hasFile: false, - reference: worker.fi, - dmsFk: docuwareId, - url, - description: document.description + ' - ' + document.state, - download: document.download, - created: document.created, - dmsType: {name: 'Docuware'}, - worker: {id: null, user: {name: document.name}}, - } - }; - Object.assign(document, defaultData); - } - }; - - return workerDocuware; -}; From ccaf56f8429052b824f6404f621758bbc8f374bd Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 11 Sep 2024 08:35:19 +0200 Subject: [PATCH 112/137] fix: setDeleted --- modules/ticket/back/methods/ticket/setDeleted.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 2afdf44ac..5000805b8 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -127,7 +127,7 @@ module.exports = Self => { id: id, url: `${url}ticket/${id}/summary` }); - await models.Chat.send(ctx, `@${salesPersonUser.name}`, message); + await models.Chat.sendCheckingPresence(ctx, `${salesPersonUser.id}`, message); } const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions); From 838b8f541fb2e81d2ac9e64f2a1b48a2d628f97d Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 11 Sep 2024 08:45:00 +0200 Subject: [PATCH 113/137] fix: setDeleted --- modules/ticket/back/methods/ticket/setDeleted.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 5000805b8..8dfe42bf8 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -127,7 +127,7 @@ module.exports = Self => { id: id, url: `${url}ticket/${id}/summary` }); - await models.Chat.sendCheckingPresence(ctx, `${salesPersonUser.id}`, message); + await models.Chat.sendCheckingPresence(ctx, salesPersonUser.id, message); } const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions); From 2ee0c93e246335e157141af1bb49f38a3ecfbe2d Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 11 Sep 2024 09:35:26 +0200 Subject: [PATCH 114/137] chore: refs #7663 fix test --- modules/ticket/back/methods/ticket/specs/setWeight.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js index c26ae7aaf..f6ef1f8e7 100644 --- a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js @@ -39,7 +39,7 @@ describe('ticket setWeight()', () => { expect(ticket.weight).toEqual(weight); }); - it('should throw an error if the user does not have enough privileges', async() => { + it('should throw an error if the user is not allocated to the same department', async() => { ctx.req.accessToken.userId = employeeId; try { const ticketId = 10; @@ -47,7 +47,7 @@ describe('ticket setWeight()', () => { await models.Ticket.setWeight(ctx, ticketId, weight, opts); } catch (e) { - expect(e.message).toEqual('You don\'t have enough privileges'); + expect(e.message).toEqual('This ticket is not allocated to your department'); } }); From ad8f27ea810b39bbc087ff32ceaf6cbf8827ecf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 11 Sep 2024 10:15:37 +0200 Subject: [PATCH 115/137] fix: refs #7213 change rounding problems --- .../vn/procedures/sale_getProblems.sql | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 40b72a878..133f3995a 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -204,9 +204,10 @@ BEGIN ) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; + -- Redondeo: cantidad incorrecta con respecto al grouping CALL buyUltimate(vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) - SELECT ticketFk, problem ,saleFk + SELECT ticketFk, problem, saleFk FROM ( SELECT sgp.ticketFk, s.id saleFk, @@ -222,24 +223,11 @@ BEGIN GROUP BY sgp.ticketFk )sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; + + DROP TEMPORARY TABLE tmp.buyUltimate; END LOOP; CLOSE vCursor; - INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) - SELECT ticketFk, problem, saleFk - FROM ( - SELECT sgp.ticketFk, - s.id saleFk, - LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem - FROM tmp.sale_getProblems sgp - JOIN ticket t ON t.id = sgp.ticketFk - JOIN sale s ON s.ticketFk = sgp.ticketFk - JOIN item i ON i.id = s.itemFk - WHERE FIND_IN_SET('hasRounding', s.problem) - GROUP BY sgp.ticketFk - ) sub - ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; - DROP TEMPORARY TABLE tItemShelvingStock_byWarehouse; END$$ DELIMITER ; From 92f305b9fd5458f13291e8f8ff5b86bdb6e864f5 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 11 Sep 2024 10:19:55 +0200 Subject: [PATCH 116/137] fix: refs #6156 proc and version --- .../vn/procedures/ticket_canAdvance.sql | 142 ++++++++++-------- .../11221-chocolateSalal/00-firstScript.sql | 15 +- 2 files changed, 85 insertions(+), 72 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index c5b918def..57c3f4235 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -1,5 +1,3 @@ - - DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN @@ -10,82 +8,90 @@ BEGIN * @param vDateToAdvance Fecha a cuando se quiere adelantar. * @param vWarehouseFk Almacén */ - DECLARE vDateInventory DATE; - SELECT inventoried INTO vDateInventory FROM config; - - CREATE OR REPLACE TEMPORARY TABLE tStock - (itemFk INT PRIMARY KEY, amount INT) - ENGINE = MEMORY; - - INSERT INTO tStock(itemFk, amount) - SELECT itemFk, SUM(quantity) amount FROM - ( - SELECT itemFk, quantity - FROM itemTicketOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryIn - WHERE landed >= vDateInventory - AND landed < vDateFuture - AND isVirtualStock = FALSE - AND warehouseInFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseOutFk = vWarehouseFk - ) t - GROUP BY itemFk HAVING amount != 0; + CALL item_getStock(vWarehouseFk, vDateToAdvance, NULL); + CALL item_getMinacum( + vWarehouseFk, + vDateToAdvance, + DATEDIFF(DATE_SUB(vDateFuture, INTERVAL 1 DAY), vDateToAdvance), + NULL + ); CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) - SELECT dest.*, - origin.*, - IFNULL(dest.nickname, origin.nickname) nickname, + SELECT origin.ticketFk futureId, + dest.ticketFk id, + dest.state, + origin.futureState, + origin.futureIpt, + dest.ipt, + origin.workerFk, + origin.futureLiters, + origin.futureLines, + dest.shipped, + origin.shipped futureShipped, + dest.totalWithVat, + origin.totalWithVat futureTotalWithVat, + dest.agency, + dest.agencyModeFk, + origin.futureAgency, + origin.agencyModeFk futureAgencyModeFk, + dest.lines, + dest.liters, + origin.futureLines - origin.hasStock AS notMovableLines, (origin.futureLines = origin.hasStock) AS isFullMovable, - origin.futureLines - origin.hasStock AS notMovableLines + dest.zoneFk, + origin.futureZoneFk, + origin.futureZoneName, + origin.classColor futureClassColor, + dest.classColor, + origin.clientFk futureClientFk, + origin.addressFk futureAddressFk, + origin.warehouseFk futureWarehouseFk, + origin.companyFk futureCompanyFk, + IFNULL(dest.nickname, origin.nickname) nickname, + dest.landed, + dest.preparation FROM ( - SELECT s.ticketFk futureId, - t.workerFk, - t.shipped futureShipped, - t.totalWithVat futureTotalWithVat, + SELECT s.ticketFk, + c.salesPersonFk workerFk, + t.shipped, + t.totalWithVat, st.name futureState, - t.addressFk futureAddressFk, am.name futureAgency, count(s.id) futureLines, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM((s.quantity <= IFNULL(tst.amount,0))) hasStock, - st.classColor futureClassColor, - ( - count(s.id) - - SUM((s.quantity <= IFNULL(tst.amount,0))) - ) notMovableLines, - ( - count(s.id) = - SUM((s.quantity <= IFNULL(tst.amount,0))) - ) isFullMovable + SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, + z.id futureZoneFk, + z.name futureZoneName, + st.classColor, + t.clientFk, + t.nickname, + t.addressFk, + t.warehouseFk, + t.companyFk, + t.agencyModeFk FROM ticket t + JOIN client c ON c.id = t.clientFk JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id JOIN `state` st ON st.id = ts.stateFk JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN `zone` z ON t.zoneFk = z.id + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tStock tst ON tst.itemFk = i.id + LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id + AND im.warehouseFk = vWarehouseFk + LEFT JOIN tmp.itemList il ON il.itemFk = i.id WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk GROUP BY t.id - ) origin - JOIN ( - SELECT t.id, - t.addressFk, + ) origin + LEFT JOIN ( + SELECT t.id ticketFk, st.name state, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t.shipped, @@ -94,9 +100,17 @@ BEGIN CAST(SUM(litros) AS DECIMAL(10,0)) liters, CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, st.classColor, - CONCAT_WS(':', - COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)), - COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) + t.clientFk, + t.nickname, + t.addressFk, + t.zoneFk, + t.warehouseFk, + t.companyFk, + t.landed, + t.agencyModeFk, + SEC_TO_TIME( + COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)) * 3600 + + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) * 60 ) preparation FROM ticket t JOIN sale s ON s.ticketFk = t.id @@ -105,17 +119,19 @@ BEGIN JOIN ticketState ts ON ts.ticketFk = t.id JOIN `state` st ON st.id = ts.stateFk JOIN agencyMode am ON t.agencyModeFk = am.id - JOIN ticketCanAdvanceConfig LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk LEFT JOIN `zone` z ON z.id = t.zoneFk LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + JOIN ticketCanAdvanceConfig tc WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t.warehouseFk = vWarehouseFk - AND st.order <= destinationOrder + AND st.order <= tc.destinationOrder GROUP BY t.id - ) dest ON dest.addressFk = origin.futureAddressFk + ) dest ON dest.addressFk = origin.addressFk WHERE origin.hasStock; - DROP TEMPORARY TABLE tStock; + DROP TEMPORARY TABLE IF EXISTS + tmp.itemList, + tmp.itemMinacum; END$$ DELIMITER ; diff --git a/db/versions/11221-chocolateSalal/00-firstScript.sql b/db/versions/11221-chocolateSalal/00-firstScript.sql index 680f0ee0e..bca742585 100644 --- a/db/versions/11221-chocolateSalal/00-firstScript.sql +++ b/db/versions/11221-chocolateSalal/00-firstScript.sql @@ -1,12 +1,9 @@ -- Place your SQL code here CREATE TABLE IF NOT EXISTS vn.ticketCanAdvanceConfig ( - id INT NOT NULL unsigned PRIMARY KEY, - destinationOrder INT NULL, - CONSTRAINT ticketCanAdvanceConfig_PK PRIMARY KEY (id) -) -ENGINE=InnoDB -DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; + id int(10) unsigned NOT NULL, + destinationOrder INT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `ticketCanAdvanceConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO vn.ticketCanAdvanceConfig - SET destinationOrder = 5; +INSERT INTO vn.ticketCanAdvanceConfig SET id =1, destinationOrder = 5; \ No newline at end of file From c21da8d258196466544549fadad1c7cd7b54c823 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 11 Sep 2024 10:31:43 +0200 Subject: [PATCH 117/137] fix: refs #7182 function name --- modules/worker/back/methods/worker-dms/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index ed0490f54..394988f9e 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -67,10 +67,10 @@ module.exports = Self => { const workerDms = await models.WorkerDms.find(allowedFilter); - const workerDocuware = filter.skip ? [] : await getDocuwareasync(ctx, id); + const workerDocuware = filter.skip ? [] : await getDocuware(ctx, id); return workerDms.concat(workerDocuware); - async function getDocuwareasync(ctx, id) { + async function getDocuware(ctx, id) { const {dmsTypeFk} = await models.Docuware.findOne({ fields: ['dmsTypeFk'], where: {code: 'hr', action: 'find'} From 011c16180da509df54fc2aec304c89f651a274ad Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Sep 2024 12:31:16 +0200 Subject: [PATCH 118/137] fix: refs #7213 buyUltimate --- db/routines/vn/procedures/sale_getProblems.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 133f3995a..da7c8d360 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -205,7 +205,7 @@ BEGIN ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; -- Redondeo: cantidad incorrecta con respecto al grouping - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(NULL, vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem, saleFk FROM ( From 87182abf7ed82754f44e66bc42c34471aa9a6ee9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 11 Sep 2024 12:47:51 +0200 Subject: [PATCH 119/137] fix: available refs #6861 --- db/routines/vn/procedures/itemShelving_add.sql | 5 ++++- db/routines/vn/procedures/sale_boxPickingPrint.sql | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index a1bca5b6c..ed22b9d92 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -46,7 +46,8 @@ BEGIN AND buyFk = vBuyFk) THEN UPDATE itemShelving - SET visible = visible + vQuantity + SET visible = visible + vQuantity, + available = available + vQuantity WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; ELSE @@ -55,6 +56,7 @@ BEGIN itemFk, shelvingFk, visible, + available, grouping, packing, packagingFk, @@ -62,6 +64,7 @@ BEGIN SELECT vItemFk, vShelvingFk, vQuantity, + available, IFNULL(vGrouping, b.grouping), IFNULL(vPacking, b.packing), IFNULL(vPackagingFk, b.packagingFk), diff --git a/db/routines/vn/procedures/sale_boxPickingPrint.sql b/db/routines/vn/procedures/sale_boxPickingPrint.sql index dbb3b6c14..bf7afbf7d 100644 --- a/db/routines/vn/procedures/sale_boxPickingPrint.sql +++ b/db/routines/vn/procedures/sale_boxPickingPrint.sql @@ -160,7 +160,10 @@ w1: WHILE vQuantity >= vPacking DO UPDATE sale SET quantity = quantity - vPacking WHERE id = vSaleFk; - UPDATE itemShelving SET visible = visible - vPacking WHERE id = vItemShelvingFk; + UPDATE itemShelving + SET visible = visible - vPacking, + available = available - vPacking + WHERE id = vItemShelvingFk; SET vNewSaleFk = NULL; From db7d5c5e5289769d642663242727680309a07eb5 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 11 Sep 2024 13:18:09 +0200 Subject: [PATCH 120/137] fix: available refs #6861 --- db/routines/vn/procedures/itemShelving_add.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index ed22b9d92..3f6c1f39d 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -56,7 +56,6 @@ BEGIN itemFk, shelvingFk, visible, - available, grouping, packing, packagingFk, @@ -64,7 +63,6 @@ BEGIN SELECT vItemFk, vShelvingFk, vQuantity, - available, IFNULL(vGrouping, b.grouping), IFNULL(vPacking, b.packing), IFNULL(vPackagingFk, b.packagingFk), From d15be5100d8b58cfad3ee673f0008b30196582e6 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 11 Sep 2024 13:42:04 +0200 Subject: [PATCH 121/137] refactor: refs #7952 Deprecate creditInsurance.creditClassification --- db/routines/vn/procedures/creditInsurance_getRisk.sql | 2 +- .../vn/triggers/creditInsurance_afterInsert.sql | 2 +- .../vn/triggers/creditInsurance_beforeInsert.sql | 10 ---------- db/routines/vn/triggers/solunionCAP_afterInsert.sql | 2 +- db/routines/vn/triggers/solunionCAP_afterUpdate.sql | 4 ++-- db/routines/vn/triggers/solunionCAP_beforeDelete.sql | 2 +- db/versions/11224-whiteMastic/00-firstScript.sql | 2 ++ 7 files changed, 8 insertions(+), 16 deletions(-) delete mode 100644 db/routines/vn/triggers/creditInsurance_beforeInsert.sql create mode 100644 db/versions/11224-whiteMastic/00-firstScript.sql diff --git a/db/routines/vn/procedures/creditInsurance_getRisk.sql b/db/routines/vn/procedures/creditInsurance_getRisk.sql index ea19f8aef..5562c91d4 100644 --- a/db/routines/vn/procedures/creditInsurance_getRisk.sql +++ b/db/routines/vn/procedures/creditInsurance_getRisk.sql @@ -10,7 +10,7 @@ BEGIN SELECT * FROM ( SELECT cc.client clientFk, ci.grade FROM creditClassification cc - JOIN creditInsurance ci ON cc.id = ci.creditClassification + JOIN creditInsurance ci ON cc.id = ci.creditClassificationFk WHERE dateEnd IS NULL ORDER BY ci.creationDate DESC LIMIT 10000000000000000000) t1 diff --git a/db/routines/vn/triggers/creditInsurance_afterInsert.sql b/db/routines/vn/triggers/creditInsurance_afterInsert.sql index c865f31a4..f4857a730 100644 --- a/db/routines/vn/triggers/creditInsurance_afterInsert.sql +++ b/db/routines/vn/triggers/creditInsurance_afterInsert.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditInsurance_afterIn BEGIN UPDATE `client` c JOIN vn.creditClassification cc ON cc.client = c.id - SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassification; + SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassificationFk; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/creditInsurance_beforeInsert.sql b/db/routines/vn/triggers/creditInsurance_beforeInsert.sql deleted file mode 100644 index 8e036d373..000000000 --- a/db/routines/vn/triggers/creditInsurance_beforeInsert.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditInsurance_beforeInsert` - BEFORE INSERT ON `creditInsurance` - FOR EACH ROW -BEGIN - IF NEW.creditClassificationFk THEN - SET NEW.creditClassification = NEW.creditClassificationFk; - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/solunionCAP_afterInsert.sql b/db/routines/vn/triggers/solunionCAP_afterInsert.sql index b4df7dc61..d09cadd95 100644 --- a/db/routines/vn/triggers/solunionCAP_afterInsert.sql +++ b/db/routines/vn/triggers/solunionCAP_afterInsert.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_afterInsert BEGIN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql index ccfba96f2..1199067bb 100644 --- a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql +++ b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql @@ -6,12 +6,12 @@ BEGIN IF NEW.dateLeaving IS NOT NULL THEN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; ELSE UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; END IF; END$$ diff --git a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql index a8b6732c1..7913a0d78 100644 --- a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql +++ b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDelet BEGIN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; END$$ DELIMITER ; diff --git a/db/versions/11224-whiteMastic/00-firstScript.sql b/db/versions/11224-whiteMastic/00-firstScript.sql new file mode 100644 index 000000000..52267cd91 --- /dev/null +++ b/db/versions/11224-whiteMastic/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.creditInsurance + CHANGE creditClassification creditClassification__ int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11'; From 7e06c2ab37eefd06b850c01645cf4d66f99e2515 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 11 Sep 2024 13:57:03 +0200 Subject: [PATCH 122/137] fix: available refs #6861 --- db/routines/vn/procedures/itemShelving_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index 3f6c1f39d..98ec9b088 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -69,6 +69,6 @@ BEGIN id FROM buy b WHERE id = vBuyFk; - END IF; + END IF; END$$ DELIMITER ; \ No newline at end of file From 889f3bdab4e9e3fae0e443bd193c5009d4d9771c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Sep 2024 14:12:07 +0200 Subject: [PATCH 123/137] fix: refs #7213 risk F11 --- db/routines/vn/procedures/ticket_getProblems.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index f83351456..e91d62613 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -36,7 +36,7 @@ BEGIN UPDATE tmp.ticket_problems SET totalProblems = ( (isFreezed) + - (hasRisk) + + (hasHighRisk) + (hasTicketRequest) + (!isTaxDataChecked) + (hasComponentLack) + From 728c40916c4dc759afe2a0e56bb8ffb5e1acb7fd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Sep 2024 14:38:58 +0200 Subject: [PATCH 124/137] refactor: refs #7895 workerDocument to workerDms --- db/dump/fixtures.before.sql | 2 +- ...ent_afterDelete.sql => workerDms_afterDelete.sql} | 6 +++--- ...t_beforeInsert.sql => workerDms_beforeInsert.sql} | 4 ++-- ...t_beforeUpdate.sql => workerDms_beforeUpdate.sql} | 4 ++-- db/versions/11225-goldenLaurel/00-firstScript.sql | 1 + db/versions/11225-goldenLaurel/01-firstScript.sql | 1 + db/versions/11225-goldenLaurel/02-firstScript.sql | 1 + modules/worker/back/methods/worker-dms/filter.js | 7 ++++--- modules/worker/back/models/worker-dms.json | 12 +++--------- myt.config.yml | 2 +- 10 files changed, 19 insertions(+), 21 deletions(-) rename db/routines/vn/triggers/{workerDocument_afterDelete.sql => workerDms_afterDelete.sql} (71%) rename db/routines/vn/triggers/{workerDocument_beforeInsert.sql => workerDms_beforeInsert.sql} (73%) rename db/routines/vn/triggers/{workerDocument_beforeUpdate.sql => workerDms_beforeUpdate.sql} (73%) create mode 100644 db/versions/11225-goldenLaurel/00-firstScript.sql create mode 100644 db/versions/11225-goldenLaurel/01-firstScript.sql create mode 100644 db/versions/11225-goldenLaurel/02-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ea689c609..0a797f7ec 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2488,7 +2488,7 @@ INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`) (1104, 2), (1104, 3); -INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker`) +INSERT INTO `vn`.`workerDms`(`id`, `workerFk`, `dmsFk`,`isReadableByWorker`) VALUES (1, 1106, 4, TRUE), (2, 1107, 3, FALSE); diff --git a/db/routines/vn/triggers/workerDocument_afterDelete.sql b/db/routines/vn/triggers/workerDms_afterDelete.sql similarity index 71% rename from db/routines/vn/triggers/workerDocument_afterDelete.sql rename to db/routines/vn/triggers/workerDms_afterDelete.sql index 8d4878248..bfb7d481e 100644 --- a/db/routines/vn/triggers/workerDocument_afterDelete.sql +++ b/db/routines/vn/triggers/workerDms_afterDelete.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_afterDelete` - AFTER DELETE ON `workerDocument` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_afterDelete` + AFTER DELETE ON `workerDms` FOR EACH ROW BEGIN INSERT INTO workerLog SET `action` = 'delete', - `changedModel` = 'WorkerDocument', + `changedModel` = 'WorkerDms', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); END$$ diff --git a/db/routines/vn/triggers/workerDocument_beforeInsert.sql b/db/routines/vn/triggers/workerDms_beforeInsert.sql similarity index 73% rename from db/routines/vn/triggers/workerDocument_beforeInsert.sql rename to db/routines/vn/triggers/workerDms_beforeInsert.sql index f0675e68f..a52c60961 100644 --- a/db/routines/vn/triggers/workerDocument_beforeInsert.sql +++ b/db/routines/vn/triggers/workerDms_beforeInsert.sql @@ -1,6 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_beforeInsert` - BEFORE INSERT ON `workerDocument` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_beforeInsert` + BEFORE INSERT ON `workerDms` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); diff --git a/db/routines/vn/triggers/workerDocument_beforeUpdate.sql b/db/routines/vn/triggers/workerDms_beforeUpdate.sql similarity index 73% rename from db/routines/vn/triggers/workerDocument_beforeUpdate.sql rename to db/routines/vn/triggers/workerDms_beforeUpdate.sql index ffb6efd74..564064444 100644 --- a/db/routines/vn/triggers/workerDocument_beforeUpdate.sql +++ b/db/routines/vn/triggers/workerDms_beforeUpdate.sql @@ -1,6 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_beforeUpdate` - BEFORE UPDATE ON `workerDocument` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_beforeUpdate` + BEFORE UPDATE ON `workerDms` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); diff --git a/db/versions/11225-goldenLaurel/00-firstScript.sql b/db/versions/11225-goldenLaurel/00-firstScript.sql new file mode 100644 index 000000000..87f521a03 --- /dev/null +++ b/db/versions/11225-goldenLaurel/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.workerDocument CHANGE worker workerFk int(10) unsigned DEFAULT NULL NULL; diff --git a/db/versions/11225-goldenLaurel/01-firstScript.sql b/db/versions/11225-goldenLaurel/01-firstScript.sql new file mode 100644 index 000000000..3aa3a1876 --- /dev/null +++ b/db/versions/11225-goldenLaurel/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.workerDocument CHANGE document dmsFk int(11) DEFAULT NULL NULL; diff --git a/db/versions/11225-goldenLaurel/02-firstScript.sql b/db/versions/11225-goldenLaurel/02-firstScript.sql new file mode 100644 index 000000000..d0e789534 --- /dev/null +++ b/db/versions/11225-goldenLaurel/02-firstScript.sql @@ -0,0 +1 @@ +RENAME TABLE vn.workerDocument TO vn.workerDms; diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index b7802a689..8feac3658 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -38,10 +38,11 @@ module.exports = Self => { const account = await models.VnUser.findById(userId); const stmt = new ParameterizedSQL( `SELECT d.id, d.id dmsFk - FROM workerDocument wd - JOIN dms d ON d.id = wd.document + FROM workerDms wd + JOIN dms d ON d.id = wd.dmsFk JOIN dmsType dt ON dt.id = d.dmsTypeFk - LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk AND rr.role = ? + LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk + AND rr.role = ? `, [account.roleFk] ); const yourOwnDms = {and: [{isReadableByWorker: true}, {worker: userId}]}; diff --git a/modules/worker/back/models/worker-dms.json b/modules/worker/back/models/worker-dms.json index a5c0f30b2..ef5684025 100644 --- a/modules/worker/back/models/worker-dms.json +++ b/modules/worker/back/models/worker-dms.json @@ -6,7 +6,7 @@ }, "options": { "mysql": { - "table": "workerDocument" + "table": "workerDms" } }, "properties": { @@ -16,17 +16,11 @@ }, "dmsFk": { "type": "number", - "required": true, - "mysql": { - "columnName": "document" - } + "required": true }, "workerFk": { "type": "number", - "required": true, - "mysql": { - "columnName": "worker" - } + "required": true }, "isReadableByWorker": { "type": "boolean" diff --git a/myt.config.yml b/myt.config.yml index ffa4188b2..1a0a138f0 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -375,7 +375,7 @@ localFixtures: - workerBosses - workerBusinessType - workerConfig - - workerDocument + - workerDms - workerLog - workerMana - workerManaExcluded From 0feb44e404307638223a753e442dd7cd13e3110e Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 11 Sep 2024 15:07:37 +0200 Subject: [PATCH 125/137] refactor: refs #7923 Delete Logiflora functions --- db/routines/edi/events/floramondo.sql | 8 - .../procedures/floramondo_offerRefresh.sql | 522 ------------------ .../vn/functions/entry_getForLogiflora.sql | 64 --- .../vn/functions/travel_getForLogiflora.sql | 52 -- 4 files changed, 646 deletions(-) delete mode 100644 db/routines/edi/events/floramondo.sql delete mode 100644 db/routines/edi/procedures/floramondo_offerRefresh.sql delete mode 100644 db/routines/vn/functions/entry_getForLogiflora.sql delete mode 100644 db/routines/vn/functions/travel_getForLogiflora.sql diff --git a/db/routines/edi/events/floramondo.sql b/db/routines/edi/events/floramondo.sql deleted file mode 100644 index 0a38f3537..000000000 --- a/db/routines/edi/events/floramondo.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `edi`.`floramondo` - ON SCHEDULE EVERY 6 MINUTE - STARTS '2022-01-28 09:52:45.000' - ON COMPLETION NOT PRESERVE - DISABLE -DO CALL edi.floramondo_offerRefresh()$$ -DELIMITER ; diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql deleted file mode 100644 index 18d3f8b7e..000000000 --- a/db/routines/edi/procedures/floramondo_offerRefresh.sql +++ /dev/null @@ -1,522 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() -proc: BEGIN - DECLARE vLanded DATETIME; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vFreeId INT; - DECLARE vSupplyResponseFk INT; - DECLARE vLastInserted DATETIME; - DECLARE vIsAuctionDay BOOLEAN; - DECLARE vMaxNewItems INT DEFAULT 10000; - DECLARE vStartingTime DATETIME; - DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043'; - DECLARE vDayRange INT; - - DECLARE cur1 CURSOR FOR - SELECT id - FROM edi.item_free; - - DECLARE cur2 CURSOR FOR - SELECT srId - FROM itemToInsert; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('edi.floramondo_offerRefresh'); - SET @isTriggerDisabled = FALSE; - RESIGNAL; - END; - - IF 'test' = (SELECT environment FROM util.config) THEN - LEAVE proc; - END IF; - - IF !GET_LOCK('edi.floramondo_offerRefresh', 0) THEN - LEAVE proc; - END IF; - - SELECT dayRange INTO vDayRange - FROM offerRefreshConfig; - - IF vDayRange IS NULL THEN - CALL util.throw("Variable vDayRange not declared"); - END IF; - - SET vStartingTime = util.VN_NOW(); - - TRUNCATE edi.offerList; - - INSERT INTO edi.offerList(supplier, total) - SELECT v.name, COUNT(DISTINCT sr.ID) total - FROM edi.supplyResponse sr - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - WHERE sr.NumberOfUnits > 0 - AND sr.EmbalageCode != 999 - GROUP BY sr.vmpID; - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(*) total - FROM edi.supplyOffer sr - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.`filter` = sub.total; - - -- Elimina de la lista de items libres aquellos que ya existen - DELETE itf.* - FROM edi.item_free itf - JOIN vn.item i ON i.id = itf.id; - - CREATE OR REPLACE TEMPORARY TABLE tmp - (INDEX (`Item_ArticleCode`)) - ENGINE = MEMORY - SELECT t.* - FROM ( - SELECT * - FROM edi.supplyOffer - ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, - NumberOfUnits DESC LIMIT 10000000000000000000) t - GROUP BY t.srId; - - CREATE OR REPLACE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`), - INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`), - INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`)) - ENGINE = MEMORY - SELECT so.*, - ev1.type_description s1Value, - ev2.type_description s2Value, - ev3.type_description s3Value, - ev4.type_description s4Value, - ev5.type_description s5Value, - ev6.type_description s6Value, - eif1.feature ef1, - eif2.feature ef2, - eif3.feature ef3, - eif4.feature ef4, - eif5.feature ef5, - eif6.feature ef6 - FROM tmp so - LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode - AND eif1.presentation_order = 1 - AND eif1.expiry_date IS NULL - LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode - AND eif2.presentation_order = 2 - AND eif2.expiry_date IS NULL - LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode - AND eif3.presentation_order = 3 - AND eif3.expiry_date IS NULL - LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode - AND eif4.presentation_order = 4 - AND eif4.expiry_date IS NULL - LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode - AND eif5.presentation_order = 5 - AND eif5.expiry_date IS NULL - LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode - AND eif6.presentation_order = 6 - AND eif6.expiry_date IS NULL - LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature - AND so.s1 = ev1.type_value - LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature - AND so.s2 = ev2.type_value - LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature - AND so.s3 = ev3.type_value - LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature - AND so.s4 = ev4.type_value - LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature - AND so.s5 = ev5.type_value - LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature - AND so.s6 = ev6.type_value - ORDER BY Price; - - DROP TEMPORARY TABLE tmp; - - DELETE o - FROM edi.offer o - LEFT JOIN vn.tag t1 ON t1.ediTypeFk = o.ef1 AND t1.overwrite = 'size' - LEFT JOIN vn.tag t2 ON t2.ediTypeFk = o.ef2 AND t2.overwrite = 'size' - LEFT JOIN vn.tag t3 ON t3.ediTypeFk = o.ef3 AND t3.overwrite = 'size' - LEFT JOIN vn.tag t4 ON t4.ediTypeFk = o.ef4 AND t4.overwrite = 'size' - LEFT JOIN vn.tag t5 ON t5.ediTypeFk = o.ef5 AND t5.overwrite = 'size' - LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size' - JOIN vn.floramondoConfig fc ON TRUE - WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize) - OR (t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize) - OR (t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize) - OR (t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize) - OR (t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize) - OR (t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize); - - START TRANSACTION; - - -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos - UPDATE IGNORE edi.offer o - JOIN vn.item i - ON i.name = o.product_name - AND i.subname <=> o.company_name - AND i.value5 <=> o.s1Value - AND i.value6 <=> o.s2Value - AND i.value7 <=> o.s3Value - AND i.value8 <=> o.s4Value - AND i.value9 <=> o.s5Value - AND i.value10 <=> o.s6Value - AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask - AND i.EmbalageCode <=> o.EmbalageCode - AND i.quality <=> o.Quality - JOIN vn.itemType it ON it.id = i.typeFk - LEFT JOIN vn.sale s ON s.itemFk = i.id - LEFT JOIN vn.ticket t ON t.id = s.ticketFk - AND t.shipped > (util.VN_CURDATE() - INTERVAL 1 WEEK) - LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk - AND po.OrderTradeLineDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK) - SET i.supplyResponseFk = o.srID - WHERE (sr.ID IS NULL - OR sr.NumberOfUnits = 0 - OR di.LatestOrderDateTime < util.VN_NOW() - OR di.ID IS NULL) - AND it.isInventory - AND t.id IS NULL - AND po.id IS NULL; - - CREATE OR REPLACE TEMPORARY TABLE itemToInsert - ENGINE = MEMORY - SELECT o.*, CAST(NULL AS DECIMAL(6,0)) itemFk - FROM edi.offer o - LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId - WHERE i.id IS NULL - LIMIT vMaxNewItems; - - -- Reciclado de nº de item - OPEN cur1; - OPEN cur2; - - read_loop: LOOP - - FETCH cur2 INTO vSupplyResponseFk; - FETCH cur1 INTO vFreeId; - - IF vDone THEN - LEAVE read_loop; - END IF; - - UPDATE itemToInsert - SET itemFk = vFreeId - WHERE srId = vSupplyResponseFk; - - END LOOP; - - CLOSE cur1; - CLOSE cur2; - - -- Insertamos todos los items en Articles de la oferta - INSERT INTO vn.item(id, - `name`, - longName, - subName, - expenseFk, - typeFk, - intrastatFk, - originFk, - supplyResponseFk, - numberOfItemsPerCask, - embalageCode, - quality, - isFloramondo) - SELECT iti.itemFk, - iti.product_name, - iti.product_name, - iti.company_name, - iti.expenseFk, - iti.itemTypeFk, - iti.intrastatFk, - iti.originFk, - iti.`srId`, - iti.NumberOfItemsPerCask, - iti.EmbalageCode, - iti.Quality, - TRUE - FROM itemToInsert iti; - - -- Inserta la foto de los articulos nuevos (prioridad alta) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) - SELECT i.id, PictureReference - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.srId - WHERE PictureReference IS NOT NULL - AND i.image IS NULL; - - INSERT INTO edi.`log`(tableName, fieldName,fieldValue) - SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*) - FROM vn.itemImageQueue - WHERE attempts = 0; - - -- Inserta si se añadiesen tags nuevos - INSERT IGNORE INTO vn.tag (name, ediTypeFk) - SELECT description, type_id FROM edi.type; - - -- Desabilita el trigger para recalcular los tags al final - SET @isTriggerDisabled = TRUE; - - -- Inserta los tags sólo en los articulos nuevos - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.product_name, 1 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Producto' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.product_name IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.Quality, 3 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Calidad' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.Quality IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.company_name, 4 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Productor' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.company_name IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s1Value, 5 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef1 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s1Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s2Value, 6 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef2 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s2Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s3Value, 7 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef3 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s3Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s4Value, 8 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef4 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s4Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s5Value, 9 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef5 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s5Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s6Value, 10 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef6 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s6Value IS NULL; - - INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11 - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - JOIN vn.tag t ON t.`name` = 'Color' - LEFT JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode - LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id - AND tp.`description` = 'Hoofdkleur 1' - LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value - LEFT JOIN vn.itemInk ik ON ik.longName = i.longName - WHERE ink.name IS NOT NULL - OR ik.color IS NOT NULL; - - CREATE OR REPLACE TABLE tmp.item - (PRIMARY KEY (id)) - SELECT i.id FROM vn.item i - JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`; - - CALL vn.item_refreshTags(); - - DROP TABLE tmp.item; - - SELECT MIN(LatestDeliveryDateTime) INTO vLanded - FROM edi.supplyResponse sr - JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID - JOIN vn.floramondoConfig fc - WHERE mp.isLatestOrderDateTimeRelevant - AND di.LatestOrderDateTime > IF( - fc.MaxLatestOrderHour > HOUR(util.VN_NOW()), - util.VN_CURDATE(), - util.VN_CURDATE() + INTERVAL 1 DAY); - - UPDATE vn.floramondoConfig - SET nextLanded = vLanded - WHERE vLanded IS NOT NULL; - - -- Elimina la oferta obsoleta - UPDATE vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID - LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk - SET b.quantity = 0 - WHERE (IFNULL(di.LatestOrderDateTime,util.VN_NOW()) <= util.VN_NOW() - OR i.supplyResponseFk IS NULL - OR sr.NumberOfUnits = 0) - AND am.name = 'LOGIFLORA' - AND e.isRaid; - - -- Localiza las entradas de cada almacen - UPDATE edi.warehouseFloramondo - SET entryFk = vn.entry_getForLogiflora(vLanded + INTERVAL travellingDays DAY, warehouseFk); - - IF vLanded IS NOT NULL THEN - -- Actualiza la oferta existente - UPDATE vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.offer o ON i.supplyResponseFk = o.`srId` - SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask, - b.buyingValue = o.price - WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask - OR b.buyingValue <> o.price); - - -- Inserta el resto - SET vLastInserted := util.VN_NOW(); - - -- Inserta la oferta - INSERT INTO vn.buy ( - entryFk, - itemFk, - quantity, - buyingValue, - stickers, - packing, - `grouping`, - groupingMode, - packagingFk, - deliveryFk) - SELECT wf.entryFk, - i.id, - o.NumberOfUnits * o.NumberOfItemsPerCask quantity, - o.Price, - o.NumberOfUnits etiquetas, - o.NumberOfItemsPerCask packing, - GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`, - 'packing', - o.embalageCode, - o.diId - FROM edi.offer o - JOIN vn.item i ON i.supplyResponseFk = o.srId - JOIN edi.warehouseFloramondo wf - JOIN vn.packaging p ON p.id - LIKE o.embalageCode - LEFT JOIN vn.buy b ON b.itemFk = i.id - AND b.entryFk = wf.entryFk - WHERE b.id IS NULL; -- Quitar esta linea y mirar de crear los packages a tiempo REAL - - INSERT INTO vn.itemCost( - itemFk, - warehouseFk, - cm3, - cm3delivery) - SELECT b.itemFk, - wf.warehouseFk, - @cm3 := vn.buy_getUnitVolume(b.id), - IFNULL((vc.standardFlowerBox * 1000) / i.packingOut, @cm3) - FROM warehouseFloramondo wf - JOIN vn.volumeConfig vc - JOIN vn.buy b ON b.entryFk = wf.entryFk - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.itemCost ic ON ic.itemFk = b.itemFk - AND ic.warehouseFk = wf.warehouseFk - WHERE (ic.cm3 IS NULL OR ic.cm3 = 0) - ON DUPLICATE KEY UPDATE cm3 = @cm3, cm3delivery = IFNULL((vc.standardFlowerBox * 1000) / i.packingOut, @cm3); - - CREATE OR REPLACE TEMPORARY TABLE tmp.buyRecalc - SELECT b.id - FROM vn.buy b - JOIN warehouseFloramondo wf ON wf.entryFk = b.entryFk - WHERE b.created >= vLastInserted; - - CALL vn.buy_recalcPrices(); - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.warehouse w ON w.id = wf.warehouseFk - WHERE w.name = 'VNH' - AND b.quantity > 0 - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.vnh = sub.total; - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.warehouse w ON w.id = wf.warehouseFk - WHERE w.name = 'ALGEMESI' - AND b.quantity > 0 - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.algemesi = sub.total; - END IF; - - DROP TEMPORARY TABLE - edi.offer, - itemToInsert; - - SET @isTriggerDisabled = FALSE; - - COMMIT; - - -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias - UPDATE vn.item i - SET typeFk = 121 - WHERE i.longName LIKE 'Rosa Garden %' - AND typeFk = 17; - - UPDATE vn.item i - SET typeFk = 156 - WHERE i.longName LIKE 'Rosa ec %' - AND typeFk = 17; - - -- Refresca las fotos de los items existentes que mostramos (prioridad baja) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url, priority) - SELECT i.id, sr.PictureReference, 100 - FROM edi.supplyResponse sr - JOIN vn.item i ON i.supplyResponseFk = sr.ID - JOIN edi.supplyOffer so ON so.srId = sr.ID - JOIN hedera.image i2 ON i2.name = i.image - AND i2.collectionFk = 'catalog' - WHERE i2.updated <= (UNIX_TIMESTAMP(util.VN_NOW()) - vDayRange) - AND sr.NumberOfUnits; - - INSERT INTO edi.`log` - SET tableName = 'floramondo_offerRefresh', - fieldName = 'Tiempo de proceso', - fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); - - DO RELEASE_LOCK('edi.floramondo_offerRefresh'); -END$$ -DELIMITER ; diff --git a/db/routines/vn/functions/entry_getForLogiflora.sql b/db/routines/vn/functions/entry_getForLogiflora.sql deleted file mode 100644 index 57e787afa..000000000 --- a/db/routines/vn/functions/entry_getForLogiflora.sql +++ /dev/null @@ -1,64 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getForLogiflora`(vLanded DATE, vWarehouseFk INT) - RETURNS int(11) - NOT DETERMINISTIC - READS SQL DATA -BEGIN - - /** - * Devuelve una entrada para Logiflora. Si no existe la crea. - * - * @param vLanded Fecha de llegada al almacén - * @param vWarehouseFk Identificador de vn.warehouse - */ - - DECLARE vTravelFk INT; - DECLARE vEntryFk INT; - DECLARE previousEntryFk INT; - - SET vTravelFk = vn.travel_getForLogiflora(vLanded, vWarehouseFk); - - IF vLanded THEN - - SELECT IFNULL(MAX(id),0) INTO vEntryFk - FROM vn.entry - WHERE travelFk = vTravelFk - AND isRaid; - - IF NOT vEntryFk THEN - - INSERT INTO vn.entry(travelFk, supplierFk, commission, companyFk, currencyFk, isRaid) - SELECT vTravelFk, s.id, 4, c.id, cu.id, TRUE - FROM vn.supplier s - JOIN vn.company c ON c.code = 'VNL' - JOIN vn.currency cu ON cu.code = 'EUR' - WHERE s.name = 'KONINKLIJE COOPERATIEVE BLOEMENVEILING FLORAHOLLAN'; - - SELECT MAX(id) INTO vEntryFk - FROM vn.entry - WHERE travelFk = vTravelFk; - - END IF; - - END IF; - - SELECT entryFk INTO previousEntryFk - FROM edi.warehouseFloramondo wf - WHERE wf.warehouseFk = vWarehouseFk; - - IF IFNULL(previousEntryFk,0) != vEntryFk THEN - - UPDATE buy b - SET b.printedStickers = 0 - WHERE entryFk = previousEntryFk; - - DELETE FROM buy WHERE entryFk = previousEntryFk; - - DELETE FROM entry WHERE id = previousEntryFk; - - END IF; - - RETURN vEntryFk; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/functions/travel_getForLogiflora.sql b/db/routines/vn/functions/travel_getForLogiflora.sql deleted file mode 100644 index 39c3086b7..000000000 --- a/db/routines/vn/functions/travel_getForLogiflora.sql +++ /dev/null @@ -1,52 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`travel_getForLogiflora`(vLanded DATE, vWarehouseFk INT) - RETURNS int(11) - NOT DETERMINISTIC - READS SQL DATA -BEGIN - - /** - * Devuelve un número de travel para compras de Logiflora a partir de la fecha de llegada y del almacén. - * Si no existe lo genera. - * - * @param vLanded Fecha de llegada al almacén - * @param vWarehouseFk Identificador de vn.warehouse - */ - - DECLARE vTravelFk INT; - - IF vLanded THEN - - SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk - WHERE wIn.id = vWarehouseFk - AND wOut.name = 'Holanda' - AND am.name = 'LOGIFLORA' - AND landed = vLanded; - - IF NOT vTravelFk THEN - - INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyModeFk) - SELECT vLanded, util.VN_CURDATE(), vWarehouseFk, wOut.id, am.id - FROM vn.warehouse wOut - JOIN vn.agencyMode am ON am.name = 'LOGIFLORA' - WHERE wOut.name = 'Holanda'; - - SELECT MAX(tr.id) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.id = vWarehouseFk - AND wOut.name = 'Holanda' - AND landed = vLanded; - END IF; - - END IF; - - RETURN vTravelFk; - -END$$ -DELIMITER ; From 6075ec6518d919ab7f31075b975d9431a94dac95 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Sep 2024 09:06:03 +0200 Subject: [PATCH 126/137] feat: refs #7562 Requested changes --- .../11113-bronzeDendro/00-firstScript.sql | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/db/versions/11113-bronzeDendro/00-firstScript.sql b/db/versions/11113-bronzeDendro/00-firstScript.sql index 98ac69966..63db65378 100644 --- a/db/versions/11113-bronzeDendro/00-firstScript.sql +++ b/db/versions/11113-bronzeDendro/00-firstScript.sql @@ -1,26 +1,16 @@ -ALTER TABLE util.config - ADD COLUMN dateRegex varchar(255) NULL COMMENT 'Expresión regular para obtener las fechas.', - ADD deprecatedMarkRegex varchar(255) NULL COMMENT 'Expresión regular para obtener los objetos deprecados.', - ADD daysKeepDeprecatedObjects int(11) unsigned NULL COMMENT 'Número de días que se mantendrán los objetos deprecados.'; - -UPDATE IGNORE util.config - SET dateRegex = '[0-9]{4}-[0-9]{2}-[0-9]{2}', - deprecatedMarkRegex = '__$', - daysKeepDeprecatedObjects = 60; - ALTER TABLE IF EXISTS `vn`.`payrollWorker` - MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `codpuesto__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `codcontrato__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `FAntiguedad__` date NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `grupotarifa__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `codcategoria__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-03-15 refs #6738'; + MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codpuesto__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codcontrato__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `FAntiguedad__` date NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `grupotarifa__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codcategoria__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-03-15'; ALTER TABLE IF EXISTS `vn`.`payrollWorkCenter` - MODIFY COLUMN IF EXISTS `Centro__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `domicilio__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `poblacion__` varchar(45) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `cp__` varchar(5) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `empresa_id__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738'; + MODIFY COLUMN IF EXISTS `Centro__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `domicilio__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `poblacion__` varchar(45) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `cp__` varchar(5) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `empresa_id__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15'; From b6cba2325aeefa88e5c50fd271c0beecfae43950 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Sep 2024 11:02:41 +0200 Subject: [PATCH 127/137] feat: refs #7562 myt version increased to 1.6.10 --- package.json | 2 +- pnpm-lock.yaml | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 1d3b9d253..d50631eb7 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@babel/register": "^7.7.7", "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", - "@verdnatura/myt": "^1.6.9", + "@verdnatura/myt": "^1.6.10", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4030d779..458ce647c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -143,8 +143,8 @@ devDependencies: specifier: ^19.1.0 version: 19.1.0 '@verdnatura/myt': - specifier: ^1.6.9 - version: 1.6.9 + specifier: ^1.6.10 + version: 1.6.10 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2846,8 +2846,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.9: - resolution: {integrity: sha512-29IauYra9igfdPWwV4+pVV/tBXvIg0fkVHEpSz8Zz3G3lRtzm286FN2Kv6hZkxmD/F1n52O37jN9WLiLHDTW1Q==} + /@verdnatura/myt@1.6.10: + resolution: {integrity: sha512-fih/TFll5Sn/SxxafUmYh6CW0Qwpck8PpQ63/CKm4ya8rz8gYPq0THM2B5N8yEJ3PiolMg0wrWWas9j+taAh6w==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 @@ -3306,6 +3306,7 @@ packages: /are-we-there-yet@1.1.7: resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==} + deprecated: This package is no longer supported. dependencies: delegates: 1.0.0 readable-stream: 2.3.8 @@ -6593,6 +6594,7 @@ packages: /gauge@2.7.4: resolution: {integrity: sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==} + deprecated: This package is no longer supported. dependencies: aproba: 1.2.0 console-control-strings: 1.1.0 @@ -10814,6 +10816,7 @@ packages: /npmlog@4.1.2: resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} + deprecated: This package is no longer supported. dependencies: are-we-there-yet: 1.1.7 console-control-strings: 1.1.0 @@ -11055,6 +11058,7 @@ packages: /osenv@0.1.5: resolution: {integrity: sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==} + deprecated: This package is no longer supported. dependencies: os-homedir: 1.0.2 os-tmpdir: 1.0.2 From 6b6eea78dadcc1d94d4ba3725ee5ba243d4ca599 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Sep 2024 13:21:01 +0200 Subject: [PATCH 128/137] feat: refs #7562 myt version increased to 1.6.11 --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d50631eb7..2ae7c3764 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@babel/register": "^7.7.7", "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", - "@verdnatura/myt": "^1.6.10", + "@verdnatura/myt": "^1.6.11", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 458ce647c..e2480cf4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -143,8 +143,8 @@ devDependencies: specifier: ^19.1.0 version: 19.1.0 '@verdnatura/myt': - specifier: ^1.6.10 - version: 1.6.10 + specifier: ^1.6.11 + version: 1.6.11 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2846,8 +2846,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.10: - resolution: {integrity: sha512-fih/TFll5Sn/SxxafUmYh6CW0Qwpck8PpQ63/CKm4ya8rz8gYPq0THM2B5N8yEJ3PiolMg0wrWWas9j+taAh6w==} + /@verdnatura/myt@1.6.11: + resolution: {integrity: sha512-uqdbSJSznBBzAoRkvBt600nUMEPL1PJ2v73eWMZbaoGUMiZiNAehYjs4gIrObP1cxC85JOx97XoLpG0BzPsaig==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 From 1abf6a14f95be25297e3b52e1610cf916cf81eb9 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 12 Sep 2024 13:26:09 +0200 Subject: [PATCH 129/137] fix: workerDms filter workerFk --- modules/worker/back/methods/worker-dms/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index 0d13276b1..597084e60 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -50,7 +50,7 @@ module.exports = Self => { or: [ {and: [ {isReadableByWorker: true}, - {worker: userId} + {'wd.workerFk': userId} ]}, { role: { From b1027f454b3f056892f4111441be6ab2807acafa Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 12 Sep 2024 14:13:17 +0200 Subject: [PATCH 130/137] locallyTested --- db/routines/vn/procedures/collection_new.sql | 3 ++- .../vn/procedures/productionControl.sql | 21 +++++++++++++++---- .../11229-salmonAsparagus/00-firstScript.sql | 3 +++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 db/versions/11229-salmonAsparagus/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index a5a9a61c7..53f5500a0 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -167,7 +167,8 @@ BEGIN OR LENGTH(pb.problem) OR pb.lines > vLinesLimit OR pb.m3 > vVolumeLimit - OR sub.maxSize > vSizeLimit; + OR sub.maxSize > vSizeLimit + OR pb.hasPlantTray; END IF; -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index e5323e84e..101a0f058 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -211,8 +211,6 @@ proc: BEGIN salesInParkingCount INT DEFAULT 0) ENGINE = MEMORY; - -- Insertamos todos los tickets que tienen productos parkineados - -- en sectores de previa, segun el sector CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock (PRIMARY KEY(itemFk, sectorFk)) ENGINE = MEMORY @@ -245,7 +243,6 @@ proc: BEGIN AND s.quantity > 0 GROUP BY pb.ticketFk; - -- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado UPDATE tmp.ticketWithPrevia twp JOIN ( SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount @@ -259,12 +256,28 @@ proc: BEGIN ) sub ON twp.ticketFk = sub.ticketFk SET twp.salesInParkingCount = sub.salesInParkingCount; - -- Marcamos como pendientes aquellos que no coinciden las cantidades UPDATE tmp.productionBuffer pb JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk SET pb.previousWithoutParking = TRUE WHERE twp.salesCount > twp.salesInParkingCount; + -- hasPlantTray + ALTER TABLE tmp.productionBuffer + ADD hasPlantTray BOOL DEFAULT FALSE; + + UPDATE tmp.productionBuffer pb + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_id = s.itemFk + JOIN buy b ON b.id = lb.buy_id + JOIN packaging p ON p.id = b.packagingFk + JOIN productionConfig pc + SET hasPlantTray = TRUE + WHERE ic.code = 'plant' + AND p.`depth` >= pc.minPlantTrayLength; + DROP TEMPORARY TABLE tmp.productionTicket, tmp.ticket, diff --git a/db/versions/11229-salmonAsparagus/00-firstScript.sql b/db/versions/11229-salmonAsparagus/00-firstScript.sql new file mode 100644 index 000000000..d590ed958 --- /dev/null +++ b/db/versions/11229-salmonAsparagus/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.productionConfig ADD minPlantTrayLength INT DEFAULT 53 NOT NULL +COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item'; From a0bfc2059530cee109a52d5a7e512af722b44ea8 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 12 Sep 2024 14:34:19 +0200 Subject: [PATCH 131/137] revision --- db/routines/vn/procedures/productionControl.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index 101a0f058..842a306b4 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -266,14 +266,14 @@ proc: BEGIN ADD hasPlantTray BOOL DEFAULT FALSE; UPDATE tmp.productionBuffer pb - JOIN sale s ON s.ticketFk = pb.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - JOIN itemCategory ic ON ic.id = it.categoryFk - JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_id = s.itemFk - JOIN buy b ON b.id = lb.buy_id - JOIN packaging p ON p.id = b.packagingFk - JOIN productionConfig pc + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_id = s.itemFk + JOIN buy b ON b.id = lb.buy_id + JOIN packaging p ON p.id = b.packagingFk + JOIN productionConfig pc SET hasPlantTray = TRUE WHERE ic.code = 'plant' AND p.`depth` >= pc.minPlantTrayLength; From 3d598a4ec4afcc57d5edd309f7479aa88e884f99 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Sep 2024 14:57:19 +0200 Subject: [PATCH 132/137] fix: refs #7952 Version --- db/versions/11224-whiteMastic/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/versions/11224-whiteMastic/00-firstScript.sql b/db/versions/11224-whiteMastic/00-firstScript.sql index 52267cd91..de74dfc55 100644 --- a/db/versions/11224-whiteMastic/00-firstScript.sql +++ b/db/versions/11224-whiteMastic/00-firstScript.sql @@ -1,2 +1,3 @@ +ALTER TABLE vn.creditInsurance DROP FOREIGN KEY CreditInsurance_Fk1; ALTER TABLE vn.creditInsurance CHANGE creditClassification creditClassification__ int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11'; From 93e71638581a6d9067f09b36057e551d7b621b87 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 12 Sep 2024 17:09:27 +0200 Subject: [PATCH 133/137] feat: refs #6868 refs# 6868 handleUser --- .../worker/back/methods/device/handle-user.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/device/handle-user.js b/modules/worker/back/methods/device/handle-user.js index 02b505e39..87aec378e 100644 --- a/modules/worker/back/methods/device/handle-user.js +++ b/modules/worker/back/methods/device/handle-user.js @@ -59,8 +59,12 @@ module.exports = Self => { } }, myOptions); - if (!isUserInOperator) - await models.Operator.create({'workerFk': user.id}); + if (!isUserInOperator) { + await models.Operator.create({ + 'workerFk': user.id, + 'isOnReservationMode': false + }); + } const whereCondition = deviceId ? {id: deviceId} : {android_id: androidId}; const serialNumber = @@ -103,12 +107,21 @@ module.exports = Self => { const getVersion = await models.MobileAppVersionControl.getVersion(ctx, nameApp); const combinedResult = { + ...getDataOperator.toObject(), + ...getDataUser.toObject(), + ...getVersion, + message: vMessage, + serialNumber, + }; + + const combinedResult2 = { ...getDataOperator.__data, ...getDataUser.__data, ...getVersion, message: vMessage, serialNumber, }; + console.log('conbinedResult2', combinedResult2); return combinedResult; }; }; From 2d4e6670099ef4f2ab8a38dd09923edf9e22385b Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 13 Sep 2024 07:02:30 +0200 Subject: [PATCH 134/137] feat: refs #6868 refs# 6868 handleUser --- modules/worker/back/methods/device/handle-user.js | 9 --------- .../worker/back/methods/device/specs/handle-user.spec.js | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/modules/worker/back/methods/device/handle-user.js b/modules/worker/back/methods/device/handle-user.js index 87aec378e..ac4ff2704 100644 --- a/modules/worker/back/methods/device/handle-user.js +++ b/modules/worker/back/methods/device/handle-user.js @@ -113,15 +113,6 @@ module.exports = Self => { message: vMessage, serialNumber, }; - - const combinedResult2 = { - ...getDataOperator.__data, - ...getDataUser.__data, - ...getVersion, - message: vMessage, - serialNumber, - }; - console.log('conbinedResult2', combinedResult2); return combinedResult; }; }; diff --git a/modules/worker/back/methods/device/specs/handle-user.spec.js b/modules/worker/back/methods/device/specs/handle-user.spec.js index c4cd37e33..37f76b765 100644 --- a/modules/worker/back/methods/device/specs/handle-user.spec.js +++ b/modules/worker/back/methods/device/specs/handle-user.spec.js @@ -3,7 +3,7 @@ const {models} = require('vn-loopback/server/server'); describe('Device handleUser()', () => { const ctx = {req: {accessToken: {userId: 9}}}; - it('should return data from user', async() => { + fit('should return data from user', async() => { const androidId = 'androidid11234567890'; const deviceId = 1; const nameApp = 'warehouse'; From e80fe1d0dc8a5189652a1c44ec0985e0c1afd2da Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 13 Sep 2024 07:10:47 +0200 Subject: [PATCH 135/137] feat: refs #6868 refs# 6868 handleUser --- modules/worker/back/methods/device/specs/handle-user.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/device/specs/handle-user.spec.js b/modules/worker/back/methods/device/specs/handle-user.spec.js index 37f76b765..c4cd37e33 100644 --- a/modules/worker/back/methods/device/specs/handle-user.spec.js +++ b/modules/worker/back/methods/device/specs/handle-user.spec.js @@ -3,7 +3,7 @@ const {models} = require('vn-loopback/server/server'); describe('Device handleUser()', () => { const ctx = {req: {accessToken: {userId: 9}}}; - fit('should return data from user', async() => { + it('should return data from user', async() => { const androidId = 'androidid11234567890'; const deviceId = 1; const nameApp = 'warehouse'; From ebbc1431522cd2675915f835c7e2ea74a4d357f1 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 13 Sep 2024 08:29:41 +0200 Subject: [PATCH 136/137] fix: sql wagonTypeTray --- db/versions/11088-bronzeAspidistra/00-firstScript.sql | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/db/versions/11088-bronzeAspidistra/00-firstScript.sql b/db/versions/11088-bronzeAspidistra/00-firstScript.sql index 11effc5d2..5de386df1 100644 --- a/db/versions/11088-bronzeAspidistra/00-firstScript.sql +++ b/db/versions/11088-bronzeAspidistra/00-firstScript.sql @@ -1,12 +1,10 @@ -DROP TABLE IF EXISTS vn.wagonTypeTray; - CREATE OR REPLACE TABLE vn.wagonTypeTray ( id INT UNSIGNED auto_increment NULL, wagonTypeFk int(11) unsigned NULL, height INT UNSIGNED NULL, wagonTypeColorFk int(11) unsigned NULL, CONSTRAINT wagonTypeTray_pk PRIMARY KEY (id), - CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id), + CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT wagonTypeTray_wagonTypeColor_FK FOREIGN KEY (wagonTypeColorFk) REFERENCES vn.wagonTypeColor(id) ) ENGINE=InnoDB @@ -17,5 +15,3 @@ ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultHeight INT UNSIGNED DEFAULT ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultTrayColorFk int(11) unsigned NULL COMMENT 'Default color for a base tray'; ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_wagonTypeColor_FK FOREIGN KEY (defaultTrayColorFk) REFERENCES vn.wagonTypeColor(id); -ALTER TABLE vn.wagonTypeTray DROP FOREIGN KEY wagonTypeTray_wagonType_FK; -ALTER TABLE vn.wagonTypeTray ADD CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT; From bbb3889154253962b6e59f102190812fb748df08 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 13 Sep 2024 08:54:03 +0200 Subject: [PATCH 137/137] fix: sql wagonTypeTray --- db/versions/11088-bronzeAspidistra/00-firstScript.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/versions/11088-bronzeAspidistra/00-firstScript.sql b/db/versions/11088-bronzeAspidistra/00-firstScript.sql index 5de386df1..751bbf7e3 100644 --- a/db/versions/11088-bronzeAspidistra/00-firstScript.sql +++ b/db/versions/11088-bronzeAspidistra/00-firstScript.sql @@ -1,7 +1,9 @@ +ALTER TABLE vn.collectionWagonTicket DROP FOREIGN KEY IF EXISTS collectionWagonTicket_tray; +ALTER TABLE vn.wagonConfig DROP FOREIGN KEY IF EXISTS wagonConfig_wagonTypeColor_FK; CREATE OR REPLACE TABLE vn.wagonTypeTray ( - id INT UNSIGNED auto_increment NULL, - wagonTypeFk int(11) unsigned NULL, - height INT UNSIGNED NULL, + id INT(11) UNSIGNED, + wagonTypeFk INT(11) unsigned NULL, + height INT(11) UNSIGNED NULL, wagonTypeColorFk int(11) unsigned NULL, CONSTRAINT wagonTypeTray_pk PRIMARY KEY (id), CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT, @@ -14,4 +16,4 @@ COLLATE=utf8mb3_unicode_ci; ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultHeight INT UNSIGNED DEFAULT 0 NULL COMMENT 'Default height in cm for a base tray'; ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultTrayColorFk int(11) unsigned NULL COMMENT 'Default color for a base tray'; ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_wagonTypeColor_FK FOREIGN KEY (defaultTrayColorFk) REFERENCES vn.wagonTypeColor(id); - +ALTER TABLE vn.collectionWagonTicket ADD CONSTRAINT collectionWagonTicket_tray FOREIGN KEY (trayFk) REFERENCES vn.wagonTypeTray(id);