You have two ways.
The first and the easiest one is having two databases: one for each company since the platform allows you to create endless data archives. The problem is that the two databases would not share customers and materials directly.
In this case, it is better to create two different invoice sections. The database will be unique but have two invoice tables: one for each company. This way, tax documents will be divided while customers and materials will be available.
You can manage the five different teams using the permission category to create "Team 1", "Team 2" categories, etc. Then by setting the permissions, you can ensure that each team will see only their information.