Это потому, что вам нужно вернуть обещание в своем первом .then
обратном вызове.
Измените это:
Invoice.create({
//set values for invoice object
}).then(invoice => { //update company id
//invoice belongs to a company
Company.findOne({where: {id: companyId}}).then(company => {
return invoice.setCompany(company)
})
}).then(...)
To:
Invoice.create({
//set values for invoice object
}).then(invoice => {
// return this promise
return Company.findOne({where: {id: companyId}}).then(company => {
invoice.setCompany(company)
// you also need to return your invoice object here
return invoice
})
}).then(...)