fixed agency check

This commit is contained in:
Gerard 2018-11-29 11:06:15 +01:00
parent e6bb179b61
commit 10344c7f3c
1 changed files with 5 additions and 1 deletions

View File

@ -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]);