From ad3c6dcee2b2066dacabf0b7bbfd92f69dae98f9 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 3 May 2023 14:34:36 +0200 Subject: [PATCH] wip #5595 --- loopback/common/models/vn-model.js | 12 ++++++++++++ modules/ticket/back/methods/ticket/makeInvoice.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index f469e893a..992598fb5 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -197,6 +197,18 @@ module.exports = function(Self) { * Shortcut to VnMySQL.executeP() */ rawSql(query, params, options, cb) { + const userId = options.userId; + if (userId) { + params.unshift(userId); + return this.dataSource.connector.executeP( + `CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?)); + ${query}; + CALL account.myUser_logout();`, + params, + options, + cb + ); + } return this.dataSource.connector.executeP(query, params, options, cb); }, diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 9739f5985..c2de55c96 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -29,7 +29,7 @@ module.exports = function(Self) { const date = Date.vnNew(); date.setHours(0, 0, 0, 0); - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object')