From cc5021a75f093eb830611d448f3adae4f2264036 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 26 Jun 2023 09:40:55 +0200 Subject: [PATCH] refs #5684 Removed xxxLog.create and dependences --- loopback/locale/es.json | 1 - .../back/methods/claim/claimPickupEmail.js | 8 ---- .../back/methods/client/confirmTransaction.js | 21 ---------- .../back/methods/client/updateFiscalData.js | 13 ------ modules/client/back/models/client.js | 15 ------- .../route/back/methods/route/guessPriority.js | 11 ----- .../route/back/methods/route/updateVolume.js | 15 +------ .../back/methods/ticket/componentUpdate.js | 10 ----- modules/ticket/back/methods/ticket/merge.js | 15 +------ .../back/methods/ticket/transferSales.js | 42 ------------------- .../back/methods/travel/cloneWithEntries.js | 12 ------ .../back/methods/travel/deleteThermograph.js | 15 ------- 12 files changed, 2 insertions(+), 176 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 138fa7100..ed036331f 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -177,7 +177,6 @@ "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria", "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas", "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", - "Sorts whole route": "Reordena ruta entera", "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío", diff --git a/modules/claim/back/methods/claim/claimPickupEmail.js b/modules/claim/back/methods/claim/claimPickupEmail.js index c688d6ded..1fd8eb99e 100644 --- a/modules/claim/back/methods/claim/claimPickupEmail.js +++ b/modules/claim/back/methods/claim/claimPickupEmail.js @@ -77,14 +77,6 @@ module.exports = Self => { if (salesPersonId) await models.Chat.sendCheckingPresence(ctx, salesPersonId, message); - await models.ClaimLog.create({ - originFk: args.id, - userFk: userId, - action: 'insert', - description: 'Claim-pickup-order sent', - changedModel: 'Mail' - }); - const email = new Email('claim-pickup-order', params); return email.send(); diff --git a/modules/client/back/methods/client/confirmTransaction.js b/modules/client/back/methods/client/confirmTransaction.js index fcb33c4ca..c694326a4 100644 --- a/modules/client/back/methods/client/confirmTransaction.js +++ b/modules/client/back/methods/client/confirmTransaction.js @@ -34,29 +34,8 @@ module.exports = Self => { } try { - const oldTpvTransaction = await models.TpvTransaction.findById(id, null, myOptions); - const confirm = await Self.rawSql('CALL hedera.tpvTransaction_confirmById(?)', [id], myOptions); - - const tpvTransaction = await models.TpvTransaction.findById(id, null, myOptions); - - const oldInstance = {status: oldTpvTransaction.status}; - const newInstance = {status: tpvTransaction.status}; - - const logRecord = { - originFk: tpvTransaction.clientFk, - userFk: userId, - action: 'update', - changedModel: 'TpvTransaction', - changedModelId: id, - oldInstance: oldInstance, - newInstance: newInstance - }; - - await models.ClientLog.create(logRecord, myOptions); - if (tx) await tx.commit(); - return confirm; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 697c567a3..5fd886c32 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -144,20 +144,7 @@ module.exports = Self => { if (taxDataChecked && !hasSageData) throw new UserError(`You need to fill sage information before you check verified data`); - if (args.despiteOfClient) { - const logRecord = { - originFk: clientId, - userFk: userId, - action: 'update', - changedModel: 'Client', - changedModelId: clientId, - description: $t(`Client checked as validated despite of duplication`, { - clientId: args.despiteOfClient - }) - }; - await models.ClientLog.create(logRecord, myOptions); - } // Remove unwanted properties delete args.ctx; delete args.id; diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 7b577fa98..51157e15d 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -479,21 +479,6 @@ module.exports = Self => { hasChanges = oldData.name != changes.name || oldData.active != changes.active; if (!hasChanges) return; - - const isClient = await Self.app.models.Client.count({id: oldData.id}); - if (isClient) { - const loopBackContext = LoopBackContext.getCurrentContext(); - const userId = loopBackContext.active.accessToken.userId; - const logRecord = { - originFk: oldData.id, - userFk: userId, - action: 'update', - changedModel: 'VnUser', - oldInstance: {name: oldData.name, active: oldData.active}, - newInstance: {name: changes.name, active: changes.active} - }; - await Self.app.models.ClientLog.create(logRecord); - } } }); }); diff --git a/modules/route/back/methods/route/guessPriority.js b/modules/route/back/methods/route/guessPriority.js index 67b68aa89..c6b2a9b74 100644 --- a/modules/route/back/methods/route/guessPriority.js +++ b/modules/route/back/methods/route/guessPriority.js @@ -21,7 +21,6 @@ module.exports = Self => { Self.guessPriority = async(ctx, id) => { const userId = ctx.req.accessToken.userId; - const $t = ctx.req.__; // $translate const query = `CALL vn.routeGuessPriority(?)`; const tx = await Self.beginTransaction({}); @@ -30,16 +29,6 @@ module.exports = Self => { const priority = await Self.rawSql(query, [id], options); - let logRecord = { - originFk: id, - userFk: userId, - action: 'update', - changedModel: 'Route', - description: $t('Sorts whole route') - }; - - await Self.app.models.RouteLog.create(logRecord, options); - await tx.commit(); return priority; } catch (e) { diff --git a/modules/route/back/methods/route/updateVolume.js b/modules/route/back/methods/route/updateVolume.js index cdced3882..7884dc953 100644 --- a/modules/route/back/methods/route/updateVolume.js +++ b/modules/route/back/methods/route/updateVolume.js @@ -35,24 +35,11 @@ module.exports = Self => { } try { - const originalRoute = await models.Route.findById(id, null, myOptions); - await Self.rawSql(`CALL vn.routeUpdateM3(?)`, [id], myOptions); const updatedRoute = await models.Route.findById(id, null, myOptions); - - await models.RouteLog.create({ - originFk: id, - userFk: userId, - action: 'update', - changedModel: 'Route', - changedModelId: id, - oldInstance: {m3: originalRoute.m3}, - newInstance: {m3: updatedRoute.m3} - }, myOptions); - + if (tx) await tx.commit(); - return updatedRoute; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index a8b631d7c..48aee36d4 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -242,16 +242,6 @@ module.exports = Self => { const oldProperties = await loggable.translateValues(Self, changes.old); const newProperties = await loggable.translateValues(Self, changes.new); - await models.TicketLog.create({ - originFk: args.id, - userFk: userId, - action: 'update', - changedModel: 'Ticket', - changedModelId: args.id, - oldInstance: oldProperties, - newInstance: newProperties - }, myOptions); - const salesPersonId = originalTicket.client().salesPersonFk; if (salesPersonId) { const origin = ctx.req.headers.origin; diff --git a/modules/ticket/back/methods/ticket/merge.js b/modules/ticket/back/methods/ticket/merge.js index 9a6f859f7..3c0da077f 100644 --- a/modules/ticket/back/methods/ticket/merge.js +++ b/modules/ticket/back/methods/ticket/merge.js @@ -52,22 +52,9 @@ module.exports = Self => { }); if (!ticket.originId || !ticket.destinationId) continue; - const ticketDestinationLogRecord = { - originFk: ticket.destinationId, - userFk: ctx.req.accessToken.userId, - action: 'update', - changedModel: 'Ticket', - changedModelId: ticket.destinationId, - changedModelValue: ticket.destinationId, - oldInstance: {}, - newInstance: {mergedTicket: ticket.originId} - }; - await models.Sale.updateAll({ticketFk: ticket.originId}, {ticketFk: ticket.destinationId}, myOptions); - if (await models.Ticket.setDeleted(ctx, ticket.originId, myOptions)) { - await models.TicketLog.create(ticketDestinationLogRecord, myOptions); + if (await models.Ticket.setDeleted(ctx, ticket.originId, myOptions)) await models.Chat.sendCheckingPresence(ctx, ticket.workerFk, message); - } } if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 01ada49d0..6fb9b4678 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -100,48 +100,6 @@ module.exports = Self => { await transferPartialSale( ticketId, originalSale, sale, myOptions); } - - // Log to original ticket - await models.TicketLog.create({ - originFk: id, - userFk: userId, - action: 'update', - changedModel: 'Sale', - changedModelId: sale.id, - oldInstance: { - item: originalSaleData.itemFk, - quantity: originalSaleData.quantity, - concept: originalSaleData.concept, - ticket: originalSaleData.ticketFk - }, - newInstance: { - item: sale.itemFk, - quantity: sale.quantity, - concept: sale.concept, - ticket: ticketId - } - }, myOptions); - - // Log to destination ticket - await models.TicketLog.create({ - originFk: ticketId, - userFk: userId, - action: 'update', - changedModel: 'Sale', - changedModelId: sale.id, - oldInstance: { - item: originalSaleData.itemFk, - quantity: originalSaleData.quantity, - concept: originalSaleData.concept, - ticket: originalSaleData.ticketFk - }, - newInstance: { - item: sale.itemFk, - quantity: sale.quantity, - concept: sale.concept, - ticket: ticketId - } - }, myOptions); } const isTicketEmpty = await models.Ticket.isEmpty(id, myOptions); diff --git a/modules/travel/back/methods/travel/cloneWithEntries.js b/modules/travel/back/methods/travel/cloneWithEntries.js index e5b6b1580..1337d35e5 100644 --- a/modules/travel/back/methods/travel/cloneWithEntries.js +++ b/modules/travel/back/methods/travel/cloneWithEntries.js @@ -81,18 +81,6 @@ module.exports = Self => { ] }); - const oldProperties = await loggable.translateValues(Self, travel); - const newProperties = await loggable.translateValues(Self, newTravel); - await models.TravelLog.create({ - originFk: newTravel.id, - userFk: userId, - action: 'insert', - changedModel: 'Travel', - changedModelId: newTravel.id, - oldInstance: oldProperties, - newInstance: newProperties - }); - return newTravel.id; }; }; diff --git a/modules/travel/back/methods/travel/deleteThermograph.js b/modules/travel/back/methods/travel/deleteThermograph.js index d22fc8b29..39f748eef 100644 --- a/modules/travel/back/methods/travel/deleteThermograph.js +++ b/modules/travel/back/methods/travel/deleteThermograph.js @@ -30,21 +30,6 @@ module.exports = Self => { SET travelFk = NULL, dmsFk = NULL WHERE id = ?`, [id], {userId}); - const oldInstance = { - travelFk: travelThermograph.travelFk, - dmsFk: travelThermograph.dmsFk - }; - - await models.TravelLog.create({ - originFk: travelThermograph.travelFk, - userFk: userId, - action: 'delete', - changedModel: 'TravelThermograph', - changedModelId: id, - oldInstance: oldInstance, - newInstance: {} - }); - travelThermograph.travelFk = null; travelThermograph.dmsFk = null;