From cfefc980f63dbd119fef2925307feb2374b1fcc7 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 29 Nov 2018 11:08:26 +0100 Subject: [PATCH] =?UTF-8?q?a=C3=B1adido=20if=20para=20los=20clientes=20que?= =?UTF-8?q?=20no=20tienen=20dni?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/loopback/common/models/address.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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();