diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index a1a53ca3b..db25fe715 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -36,10 +36,14 @@ module.exports = Self => { ] }); - {if (!address) - throw new UserError(`This address doesn't exist`);} + if (!address) + throw new UserError(`This address doesn't exist`); - if (address.client().type().code === 'normal') { + let agency; + if (params && params.agencyModeFk) + agency = await Self.app.models.AgencyMode.findById(params.agencyModeFk); + + if (address.client().type().code === 'normal' && (!agency || agency.code != 'refund')) { if (address.client().isFreezed) throw new UserError(`You can't create a ticket for a frozen client`); @@ -54,10 +58,6 @@ module.exports = Self => { throw new UserError(`You can't create a ticket for a client that has a debt`); } - let agency; - if (params.agencyModeFk) - agency = await Self.app.models.AgencyMode.findById(params.agencyModeFk); - if (!params.shipped && params.landed) { params.shipped = await Self.app.models.Agency.getShipped({ landed: params.landed,