Assigned licences - backend

Main changes:

added quantity of assigned licences to (user|asset),
refactoring.
@quamilek @xliiv please review.