Assigned licences - backend

Main changes:

added quantity of assigned licences to (user|asset),
refactoring.
@quamilek @xliiv please review.
What's this, isn't it duplicated? I think i've seen it already.