Both invoices and pay advice are generated by visiting an organisation form and selecting the relevant option from the context menu (the one that says Organisation). By default, invoices / pay advices (from now on we will just say "documents" where it makes no difference which we are talking about) will be produced for people who belong to the organisation whose form we are in and all organisations that sit below it on the hierarchy.
So if I was looking at the organisation called Northern in the following structure
and ran pay advice, then pay advice would be generated for care workers in Northern, Team A and Team B. To generate pay advice for just Northern, without including organisations further down the tree, I can check the Exclude Children? checkbox on the Advanced tab.
As you know, carers can be associated with any node in the organisation hierarchy, and customers must belong to "leaf" nodes. So in the diagram carers can sit anywhere, but customers can only belong in Team A, Team B, Team 1 and Team 2.
This means that if I was looking at Northern and chose to run invoices then invoices would be generated customers in Team A and Team B (since a customer cannot directly belong to Northern). It may be the case that it is not sensible to run invoices from Northern, because Team A and Team B have contracts with different local authorities who insist on different invoicing periods - this is also supported.
Document reference numbers
The documents options are only available in the organisation context menu if the organisation (or a parent organisation) has the relevant Next Ref number set up on the Invoice and Payroll tab. When running "proper" documents - i.e. not dry runs - the system picks up the next reference number from the first organisation which has a next reference going up the tree.
Northern is set up with a next Invoice number of N-1, and Team A has a next invoice ref of A-100. Team B does not have a next reference set up. Invoices are run from Northern organisation. The first invoice for a customer in Team A will get the reference A-100. Because Team B has no next reference number the system walks up the tree until it finds an organisation that has a next invoice number - in this case Northern, and allocates N-1.
This means that invoice numbers can run in a sequence per leaf node, or a sequence for your whole organisation (as well as some other options).