From ec14281a820d86bfa03155c50e587b5159ff0d99 Mon Sep 17 00:00:00 2001 From: jtubau Date: Wed, 15 Jan 2025 13:37:57 +0100 Subject: [PATCH 1/2] feat: refs #7322 add optional addressFk parameter to transferClient method --- modules/ticket/back/methods/ticket/transferClient.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/transferClient.js b/modules/ticket/back/methods/ticket/transferClient.js index 95bee008d..99e89da99 100644 --- a/modules/ticket/back/methods/ticket/transferClient.js +++ b/modules/ticket/back/methods/ticket/transferClient.js @@ -12,6 +12,10 @@ module.exports = Self => { arg: 'clientFk', type: 'number', required: true, + }, { + arg: 'addressFk', + type: 'number', + required: false, }], http: { path: `/:id/transferClient`, @@ -19,7 +23,7 @@ module.exports = Self => { } }); - Self.transferClient = async(ctx, id, clientFk, options) => { + Self.transferClient = async(ctx, id, clientFk, addressFk, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -43,10 +47,10 @@ module.exports = Self => { const client = await models.Client.findById(clientFk, {fields: ['id', 'defaultAddressFk']}, myOptions); - const address = await models.Address.findById(client.defaultAddressFk, + const address = await models.Address.findById(addressFk ? addressFk : client.defaultAddressFk, {fields: ['id', 'nickname']}, myOptions); - const attributes = {clientFk, addressFk: client.defaultAddressFk, nickname: address.nickname}; + const attributes = {clientFk, addressFk: address.id, nickname: address.nickname}; const tickets = []; const ticketIds = []; -- 2.40.1 From b78603275fceb1e53898294b66839a2b7f752286 Mon Sep 17 00:00:00 2001 From: jtubau Date: Wed, 15 Jan 2025 14:13:00 +0100 Subject: [PATCH 2/2] fix: refs #7322 reorder parameters in transferClient method for consistency --- modules/ticket/back/methods/ticket/transferClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/transferClient.js b/modules/ticket/back/methods/ticket/transferClient.js index 99e89da99..9bf2a861e 100644 --- a/modules/ticket/back/methods/ticket/transferClient.js +++ b/modules/ticket/back/methods/ticket/transferClient.js @@ -23,7 +23,7 @@ module.exports = Self => { } }); - Self.transferClient = async(ctx, id, clientFk, addressFk, options) => { + Self.transferClient = async(ctx, id, clientFk, options, addressFk) => { const models = Self.app.models; const myOptions = {}; let tx; -- 2.40.1