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) {