minor refactor
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javi Gallego 2021-01-22 14:30:46 +01:00
parent aab9797d3f
commit 7bdfb36f25
3 changed files with 20 additions and 20 deletions

View File

@ -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');

View File

@ -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,

View File

@ -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
}
}