#847 ticket.index new
This commit is contained in:
parent
632c91bcd1
commit
48dca4fe32
|
@ -61,7 +61,7 @@ module.exports = Self => {
|
|||
], transaction);
|
||||
}
|
||||
|
||||
Self.importToNewRefundTicket = async(ctx, id) => {
|
||||
Self.importToNewRefundTicket = async (ctx, id) => {
|
||||
let models = Self.app.models;
|
||||
let token = ctx.req.accessToken;
|
||||
let userId = token.userId;
|
||||
|
@ -112,7 +112,7 @@ module.exports = Self => {
|
|||
let transaction = await Self.beginTransaction({});
|
||||
|
||||
try {
|
||||
let newRefundTicket = await models.Ticket.new(params, {transaction: transaction});
|
||||
let newRefundTicket = await models.Ticket.new(ctx, params, {transaction: transaction});
|
||||
|
||||
let observation = {
|
||||
description: `Reclama ticket: ${claim.ticketFk}`,
|
||||
|
|
|
@ -132,9 +132,9 @@ module.exports = Self => {
|
|||
return ticket && ticket.id;
|
||||
}
|
||||
|
||||
async function createTicket(params, transaction) {
|
||||
let ticket = await Self.app.models.Ticket.new({
|
||||
shipped: new Date(),
|
||||
async function createTicket(ctx, params, transaction) {
|
||||
let ticket = await Self.app.models.Ticket.new(ctx,
|
||||
{shipped: new Date(),
|
||||
landed: new Date(),
|
||||
clientFk: params.clientFk,
|
||||
warehouseFk: params.warehouseFk,
|
||||
|
|
|
@ -44,12 +44,14 @@ module.exports = Self => {
|
|||
|
||||
let clientFk = address.clientFk;
|
||||
|
||||
let agency = await Self.app.models.Agency.findById(agencyModeFk);
|
||||
if (agency.code != 'refund') {
|
||||
let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
|
||||
let clientDebt = await Self.rawSql(query, [clientFk]);
|
||||
|
||||
if (clientDebt[0].debt > 0)
|
||||
throw new UserError(`You can't create an order for a client that has a debt`);
|
||||
|
||||
}
|
||||
|
||||
if (!params.userId && ctx.req && ctx.req.accessToken.userId)
|
||||
params.userId = ctx.req.accessToken.userId;
|
||||
|
|
Loading…
Reference in New Issue