How to handle license reservation/billing for groups (e.g. departments) within an admin panel?

I am working on the admin panel for a SaaS product. One need that has been conveyed by our users is the ability for groups within our product to reserve licenses that they have purchased with their budget. For instance, if the Engineering team has paid for 100 licenses, they don't want Marketing to use them up. It seems like without this functionality, companies need to perform some kind of audit at the end of the year to determine which departments used which licenses for each of the SaaS products their company uses, which is tedious. I don't necessarily want to reinvent the wheel with this one, but I'm having a hard time finding any examples of other companies that does this, which is surprising to me.

Within our product we have groups to facilitate the sharing of resources, but the problem with that is you could be part of multiple groups so we can't determine which group to subtract your license from (and we don't want to double bill!). One way I am thinking about it is through having everyone be part of one primary group. When you import users via SCIM or a CSV file we could automate the assigning of primary group by mapping to some attribute (e.g. department) in SCIM or just requesting a column in their CSV file to be called "Primary Group".

Does anyone know of any examples out there or any suggestions for how to tackle this?