fix in api : check count number of invoice before usinf invoice_id on record