This commit is contained in:
parent
1dd8fdd96b
commit
353167734e
|
@ -3,10 +3,17 @@
|
||||||
vn-td-editable {
|
vn-td-editable {
|
||||||
text {
|
text {
|
||||||
border-bottom: 1px solid rgba(0,0,0,.12);
|
border-bottom: 1px solid rgba(0,0,0,.12);
|
||||||
|
min-height: 15px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: block
|
display: block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text::after {
|
||||||
|
overflow: hidden;
|
||||||
|
content: '';
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
outline: none;
|
outline: none;
|
||||||
position: relative;
|
position: relative;
|
||||||
&:not([disabled="true"]) {
|
&:not([disabled="true"]) {
|
||||||
|
|
|
@ -80,5 +80,6 @@
|
||||||
"We weren't able to send this SMS": "No hemos podido enviar el SMS",
|
"We weren't able to send this SMS": "No hemos podido enviar el SMS",
|
||||||
"This client can't be invoiced": "Este cliente no puede ser facturado",
|
"This client can't be invoiced": "Este cliente no puede ser facturado",
|
||||||
"This ticket can't be invoiced": "Este ticket no puede ser facturado",
|
"This ticket can't be invoiced": "Este ticket no puede ser facturado",
|
||||||
"That item is not available on that day": "That item is not available on that day"
|
"That item is not available on that day": "That item is not available on that day",
|
||||||
|
"That item doesn't exists": "That item doesn't exists"
|
||||||
}
|
}
|
|
@ -31,15 +31,16 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.confirm = async ctx => {
|
Self.confirm = async ctx => {
|
||||||
|
const models = Self.app.models;
|
||||||
let transaction = await Self.beginTransaction({});
|
let transaction = await Self.beginTransaction({});
|
||||||
let options = {transaction: transaction};
|
let options = {transaction: transaction};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let item = await Self.app.models.Item.findById(ctx.args.itemFk);
|
let item = await models.Item.findById(ctx.args.itemFk);
|
||||||
if (!item)
|
if (!item)
|
||||||
throw new UserError(`That item doesn't exists`);
|
throw new UserError(`That item doesn't exists`);
|
||||||
|
|
||||||
let request = await Self.app.models.TicketRequest.findById(ctx.args.id, {
|
let request = await models.TicketRequest.findById(ctx.args.id, {
|
||||||
include: {relation: 'ticket'}
|
include: {relation: 'ticket'}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -60,15 +61,19 @@ module.exports = Self => {
|
||||||
|
|
||||||
|
|
||||||
if (request.saleFk) {
|
if (request.saleFk) {
|
||||||
let sale = await Self.app.models.Sale.findById(request.saleFk);
|
let sale = await models.Sale.findById(request.saleFk);
|
||||||
sale.updateAttributes({itemFk: ctx.args.itemFk, quantity: ctx.args.quantity, description: item.description}, options);
|
sale.updateAttributes({
|
||||||
|
itemFk: ctx.args.itemFk,
|
||||||
|
quantity: ctx.args.quantity,
|
||||||
|
description: item.description
|
||||||
|
}, options);
|
||||||
} else {
|
} else {
|
||||||
params = {
|
params = {
|
||||||
ticketFk: request.ticketFk,
|
ticketFk: request.ticketFk,
|
||||||
itemFk: ctx.args.itemFk,
|
itemFk: ctx.args.itemFk,
|
||||||
quantity: ctx.args.quantity
|
quantity: ctx.args.quantity
|
||||||
};
|
};
|
||||||
sale = await Self.app.models.Sale.create(params, options);
|
sale = await models.Sale.create(params, options);
|
||||||
request.updateAttributes({saleFk: sale.id, itemFk: sale.itemFk}, options);
|
request.updateAttributes({saleFk: sale.id, itemFk: sale.itemFk}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +81,14 @@ module.exports = Self => {
|
||||||
params = [sale.id];
|
params = [sale.id];
|
||||||
await Self.rawSql(query, params, options);
|
await Self.rawSql(query, params, options);
|
||||||
|
|
||||||
|
const message = `Se ha comprado ${params.quantity} unidades de "${item.description}" (#${params.itemFk}) `
|
||||||
|
+ `para el ticket #${params.ticketFk}`;
|
||||||
|
|
||||||
|
await models.Message.send(ctx, {
|
||||||
|
recipientFk: request.requesterFk,
|
||||||
|
message: message
|
||||||
|
}, options);
|
||||||
|
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await transaction.rollback();
|
await transaction.rollback();
|
||||||
|
|
Loading…
Reference in New Issue