Scheduling based on capacity

Hello users,

I am very new to Python, I am currently using it combined with Tableau Prep.
I currenly have a working scheduler based on 6 departments.
I have done this via a numpy running sum script that adds up all the workhours from orders based on priority.
Then I have a department capacity, based on people per department, their workhours - their vacation hours, also added up via a running sum scripts.
Then I join these values based on higher than previous day capacity and lower than this days capacity.
This provides the orders with a date in which their is capacity to perform the order.

Now I want to plan per planplace, a planplace is a combination of machines.
I can do this in a similiair way, by using the machinery capacity (basically 8 hours per day) in a running sum. But this would not take into regard the department daycapacity.

Example 25-08-2021
Department 1: 16 hours cap
Planplace 1.1: 8 hours cap
Planplace 1.2: 8 hours cap
Planplace 1.3: 8 hours cap

Current scheduler would plan 16 hours, disregarding the planplaces.
What I want to achieve, devide orders based on priority untill planplace capacity or department capacity are filled up.

Department 1: 16 hours total
Planplace 1.1: 4 hour order
Planplace 1.2: 8 hours order
Planplace 1.3: 4 hour order

Is this achievable with Python?

Kind regards,

KJ