diff --git a/services/loopback/common/models/address.js b/services/loopback/common/models/address.js index 7a94dbdc6..89848b8b9 100644 --- a/services/loopback/common/models/address.js +++ b/services/loopback/common/models/address.js @@ -17,8 +17,13 @@ module.exports = Self => { async function cannotHaveET(err, done) { let client = await Self.app.models.Client.findById(this.clientFk); - let tin = client.fi.toUpperCase(); - let cannotHaveET = /^[A-B]/.test(tin); + let cannotHaveET; + if (client && client.fi) { + let tin = client.fi.toUpperCase(); + cannotHaveET = /^[A-B]/.test(tin); + } else + cannotHaveET = false; + if (cannotHaveET && this.isEqualizated) err();