#7663 setWeight #2817
|
@ -16,13 +16,17 @@ module.exports = Self => {
|
|||
required: true,
|
||||
description: 'The weight value',
|
||||
}],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/setWeight`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.setWeight = async(ctx, ticketId, weight, invoiceable, options) => {
|
||||
Self.setWeight = async(ctx, ticketId, weight, options) => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {userId};
|
||||
|
@ -36,10 +40,10 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
const ticket = await Self.findById(ticketId, null, myOptions);
|
||||
if (ticket.weight) throw new UserError('Weight already set');
|
||||
alexm marked this conversation as resolved
|
||||
|
||||
const canEdit = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'updateAttributes');
|
||||
const ticket = await Self.findById(ticketId, null, myOptions);
|
||||
const client = await models.Client.findById(ticket.clientFk, {
|
||||
include: {relation: 'salesPersonUser'}},
|
||||
myOptions);
|
||||
|
@ -51,7 +55,10 @@ module.exports = Self => {
|
|||
where: {workerFk: {inq: [userId, salesPersonUser.id]}}
|
||||
}, myOptions);
|
||||
|
||||
if (workerDepartments[0].departmentFk != workerDepartments[1].departmentFk)
|
||||
if (
|
||||
workerDepartments.length == 2 &&
|
||||
workerDepartments[0].departmentFk != workerDepartments[1].departmentFk
|
||||
)
|
||||
throw new UserError('You don\'t have enough privileges');
|
||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
Yo daria un error mas especifico diciendo que no pueden pq no son del mismo equipo Yo daria un error mas especifico diciendo que no pueden pq no son del mismo equipo
|
||||
}
|
||||
|
||||
|
@ -63,10 +70,12 @@ module.exports = Self => {
|
|||
const [{taxArea}] = await Self.rawSql('SELECT clientTaxArea(?,?) taxArea',
|
||||
[ticket.clientFk, ticket.warehouseFk], myOptions);
|
||||
|
||||
if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice)
|
||||
if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) {
|
||||
await Self.invoiceTicketsAndPdf(ctx, [ticketId], null, myOptions);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (tx) await tx.commit();
|
||||
return false;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
|
|
Loading…
Reference in New Issue
Esta comprobación la han pedido?
Sí, me dijo que solo se debe de poder establecer el peso del ticket si no tiene.