From 10344c7f3c3f711e8aa0dfddfddaec9a4dc0bcf9 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 29 Nov 2018 11:06:15 +0100 Subject: [PATCH] fixed agency check --- services/loopback/common/methods/ticket/new.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/loopback/common/methods/ticket/new.js b/services/loopback/common/methods/ticket/new.js index d73683027..0aa4aba41 100644 --- a/services/loopback/common/methods/ticket/new.js +++ b/services/loopback/common/methods/ticket/new.js @@ -43,8 +43,12 @@ module.exports = Self => { throw new UserError(`You can't create an order for a client that doesn't has tax data verified`); let clientFk = address.clientFk; + let agency; + if (params.agency) + agency = await Self.app.models.AgencyMode.findById(params.agencyModeFk); + else + agency = {code: null}; - 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]);