From 4b302915b56d0c6ddf669eecd6f2dc85f66279d1 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 27 Jan 2021 09:14:37 +0100 Subject: [PATCH] fallo validateasync --- modules/client/back/models/receipt.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/client/back/models/receipt.js b/modules/client/back/models/receipt.js index 400bc8505..88b7bfb5b 100644 --- a/modules/client/back/models/receipt.js +++ b/modules/client/back/models/receipt.js @@ -15,9 +15,10 @@ module.exports = function(Self) { message: 'Company has to be official' }); - async function isOfficialCompany(value) { - const company = await Self.app.models.Company.findById(value); - return company.isOfficial; + async function isOfficialCompany(err, done) { + const hasCompany = await Self.app.models.Company.exists(this.companyFk); + if (!hasCompany) err(); + done(); } Self.observe('before save', async function(ctx) {