diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3bc022429c..556a16260e 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -25,6 +25,7 @@ module.exports = Self => { }); Self.sendCheckingPresence = async(ctx, recipientId, message, options) => { + console.log(ctx, recipientId, message, options); if (!recipientId) return false; const myOptions = {}; @@ -38,7 +39,10 @@ module.exports = Self => { const recipient = await models.Account.findById(recipientId, null, myOptions); // Prevent sending messages to yourself + console.log('llega'); + console.log(recipientId, userId); if (recipientId == userId) return false; + console.log('llega2'); if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); diff --git a/db/changes/10500-november/00-deletePickupContact.sql b/db/changes/10500-november/00-deletePickupContact.sql new file mode 100644 index 0000000000..6bfa662c5e --- /dev/null +++ b/db/changes/10500-november/00-deletePickupContact.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`claimConfig` DROP COLUMN `pickupContact`; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 9a0a1fff6e..34e592b9a0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1778,10 +1778,10 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina (1, 31, 4, 21, 2), (2, 32, 3, 21, 3); -INSERT INTO `vn`.`claimConfig`(`id`, `pickupContact`, `maxResponsibility`) +INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`) VALUES - (1, 'Contact description', 50), - (2, 'Contact description', 30); + (1, 50), + (2, 30); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES @@ -1791,7 +1791,7 @@ INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRa (1104, 2500, 150.00, 0.02, 0.10, 1.00); INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`) -VALUES + VALUES (1, '02676A049183', DEFAULT, 1106), (2, '02676A049183', DEFAULT, 1106), (3, '02676A049183', DEFAULT, 1107), diff --git a/modules/claim/back/methods/claim/claimPickupEmail.js b/modules/claim/back/methods/claim/claimPickupEmail.js index 4c9b865025..23f0e31ef7 100644 --- a/modules/claim/back/methods/claim/claimPickupEmail.js +++ b/modules/claim/back/methods/claim/claimPickupEmail.js @@ -9,7 +9,7 @@ module.exports = Self => { arg: 'id', type: 'number', required: true, - description: 'The client id', + description: 'The claim id', http: {source: 'path'} }, { @@ -29,24 +29,6 @@ module.exports = Self => { type: 'number', description: 'The recipient id to send to the recipient preferred language', required: false - }, - { - arg: 'ticketId', - type: 'number', - description: 'The ticket id', - required: true - }, - { - arg: 'salesPersonId', - type: 'number', - description: 'The salesPerson id', - required: false - }, - { - arg: 'clientName', - type: 'string', - description: 'The client name', - required: true } ], returns: { @@ -75,14 +57,29 @@ module.exports = Self => { for (const param in args) params[param] = args[param]; + const claim = await models.Claim.findById(args.id, { + fields: ['id', 'clientFk'], + include: { + relation: 'client', + scope: { + fields: ['name', 'salesPersonFk'] + } + } + }); + console.log(claim); + const message = $t('Claim pickup order sent', { claimId: args.id, - clientName: args.clientName, + clientName: claim.client.name, claimUrl: `${origin}/#!/claim/${args.id}/summary`, }); - if (args.salesPersonId) - await models.Chat.sendCheckingPresence(ctx, args.salesPersonId, message); + console.log(claim.client()); + const salesPersonId = claim.client().salesPersonFk; + if (claim.client().salesPersonFk) + console.log(await models.Chat.sendCheckingPresence(ctx, 25, message)); + + console.log(claim.client().salesPersonFk); await models.ClaimLog.create({ originFk: args.id, diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index b36fae3211..0dddadbe14 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -19,10 +19,7 @@ class Controller extends Descriptor { sendPickupOrder() { return this.vnEmail.send(`Claims/${this.claim.id}/claim-pickup-email`, { recipient: this.claim.client.email, - recipientId: this.claim.clientFk, - clientName: this.claim.client.name, - ticketId: this.claim.ticket.id, - salesPersonId: this.claim.client.salesPersonFk + recipientId: this.claim.clientFk }); } diff --git a/modules/claim/front/descriptor/index.spec.js b/modules/claim/front/descriptor/index.spec.js index 18ccdaff5e..e6785d3d8a 100644 --- a/modules/claim/front/descriptor/index.spec.js +++ b/modules/claim/front/descriptor/index.spec.js @@ -7,12 +7,7 @@ describe('Item Component vnClaimDescriptor', () => { const claim = { id: 2, clientFk: 1101, - client: { - email: 'client@email', - name: 'clientName', - salesPersonFk: 18 - }, - ticket: {id: 2} + client: {email: 'client@email'} }; beforeEach(ngModule('claim')); @@ -45,10 +40,7 @@ describe('Item Component vnClaimDescriptor', () => { const params = { recipient: claim.client.email, - recipientId: claim.clientFk, - clientName: claim.client.name, - ticketId: claim.ticket.id, - salesPersonId: claim.client.salesPersonFk + recipientId: claim.clientFk }; controller.sendPickupOrder(); diff --git a/package.json b/package.json index 26c164832a..be6db46a82 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "node-ssh": "^11.0.0", "object-diff": "0.0.4", "object.pick": "^1.3.0", - "puppeteer": "^18.0.5", + "puppeteer": "^19.2.0", "read-chunk": "^3.2.0", "require-yaml": "0.0.1", "sharp": "^0.31.0", diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index 51db21cb52..b8804c6040 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -8,22 +8,23 @@ module.exports = { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build() }, - created() { - this.instructions = this.$t('description.instructions', [this.id, this.ticketId]); + async serverPrefetch() { + this.ticket = await this.fetchTicket(this.id); + + if (!this.ticket) + throw new Error('Something went wrong'); + console.log(); + this.instructions = this.$t('description.instructions', [this.id, this.ticket.id]); }, - data() { - return { - instructions: String - }; + methods: { + fetchTicket(id) { + return this.findOneFromDef('ticket', [id]); + } }, props: { id: { type: [Number, String], required: true - }, - ticketId: { - type: [Number, String], - required: true } } }; diff --git a/print/templates/email/claim-pickup-order/sql/ticket.sql b/print/templates/email/claim-pickup-order/sql/ticket.sql new file mode 100644 index 0000000000..28b78c9875 --- /dev/null +++ b/print/templates/email/claim-pickup-order/sql/ticket.sql @@ -0,0 +1,4 @@ +SELECT + c.ticketFk as id +FROM claim c +WHERE c.id = ?