From 7bdfb36f25f0e7cbc6b7f9f58342be846728092f Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 22 Jan 2021 14:30:46 +0100 Subject: [PATCH] minor refactor --- db/changes/10271-wisemen/00-ACL.sql | 2 +- .../ticket/back/methods/ticket/makeInvoice.js | 28 +++++++++---------- .../back/models/print-server-queue.json | 10 +++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/db/changes/10271-wisemen/00-ACL.sql b/db/changes/10271-wisemen/00-ACL.sql index 1c1a64a30..e4b84a3e4 100644 --- a/db/changes/10271-wisemen/00-ACL.sql +++ b/db/changes/10271-wisemen/00-ACL.sql @@ -1,3 +1,3 @@ INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) - VALUES ('printServerQueue', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); + VALUES ('PrintServerQueue', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('FixedPrice', '*', '*', 'ALLOW', 'ROLE', 'buyer'); diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 45e7a615c..29099e379 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -25,36 +25,36 @@ module.exports = function(Self) { }); Self.makeInvoice = async(ctx, id) => { - let userId = ctx.req.accessToken.userId; - let models = Self.app.models; - let tx = await Self.beginTransaction({}); + const userId = ctx.req.accessToken.userId; + const models = Self.app.models; + const tx = await Self.beginTransaction({}); try { - let options = {transaction: tx}; + const options = {transaction: tx}; - let filter = {fields: ['id', 'clientFk', 'companyFk']}; - let ticket = await models.Ticket.findById(id, filter, options); + const filter = {fields: ['id', 'clientFk', 'companyFk']}; + const ticket = await models.Ticket.findById(id, filter, options); - let clientCanBeInvoiced = await models.Client.canBeInvoiced(ticket.clientFk); + const clientCanBeInvoiced = await models.Client.canBeInvoiced(ticket.clientFk); if (!clientCanBeInvoiced) throw new UserError(`This client can't be invoiced`); - let ticketCanBeInvoiced = await models.Ticket.canBeInvoiced(ticket.id); + const ticketCanBeInvoiced = await models.Ticket.canBeInvoiced(ticket.id); if (!ticketCanBeInvoiced) throw new UserError(`This ticket can't be invoiced`); - let query = `SELECT vn.invoiceSerial(?, ?, ?) AS serial`; - let [result] = await Self.rawSql(query, [ticket.clientFk, ticket.companyFk, 'R'], options); - let serial = result.serial; + const query = `SELECT vn.invoiceSerial(?, ?, ?) AS serial`; + const [result] = await Self.rawSql(query, [ticket.clientFk, ticket.companyFk, 'R'], options); + const serial = result.serial; await Self.rawSql('CALL invoiceFromTicket(?)', [id], options); await Self.rawSql('CALL invoiceOut_new(?, CURDATE(), null, @invoiceId)', [serial], options); - let [resultInvoice] = await Self.rawSql('SELECT @invoiceId id', [], options); + const [resultInvoice] = await Self.rawSql('SELECT @invoiceId id', [], options); - let invoiceId = resultInvoice.id; + const invoiceId = resultInvoice.id; - let ticketInvoice = await models.Ticket.findById(id, {fields: ['refFk']}, options); + const ticketInvoice = await models.Ticket.findById(id, {fields: ['refFk']}, options); await models.TicketLog.create({ originFk: ticket.id, diff --git a/modules/ticket/back/models/print-server-queue.json b/modules/ticket/back/models/print-server-queue.json index fc1a972f0..fef7f3b3e 100644 --- a/modules/ticket/back/models/print-server-queue.json +++ b/modules/ticket/back/models/print-server-queue.json @@ -9,22 +9,22 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "priorityFk": { - "type": "Number" + "type": "number" }, "reportFk": { - "type": "Number", + "type": "number", "required": true }, "param1": { - "type": "Number" + "type": "number" }, "workerFk": { - "type": "Number", + "type": "number", "required": true } }