When a class session is about to be created, students may or may not have the required amount of hours to make up for what the class requires.
So if they turn to be negative, they should somehow pay for those hours, but simply subtracting their hours gives no context whatsoever as to how they're consuming the hours (and how much they should pay for their debt later on).
So it would be useful if we can detect which students are the ones that don't have enough hours and allow the user to set either the rate that they should pay those hours for or simply registering how much should they pay for that debt.
Proposed approach
Class creation form should either async validate or handle in backend when there are students that don't have enough hours.
if all okay, simply create the class and subtract the hours from each.
if there are students that don't have enough hours to cover for the class, they should be pointed out, but this BEFORE class creation, so we make sure that the class is created only after the debts have been set.
Once the debt have been set, class should create successfully. And the students that did not have enough hours for the class will be left as debtors
Tech considerations
Create StudentDebt table with studentIdhoursrate (which could also be custom)
thought about using Hour here but since I want to be able to set a custom rate it might not be enough
In student detail view, debt should show with hours and the total amount that they owe
The debt should be set in the same transaction as the class session creation to avoid creating debts if the class session fails to create
When a class session is about to be created, students may or may not have the required amount of hours to make up for what the class requires.
So if they turn to be negative, they should somehow pay for those hours, but simply subtracting their hours gives no context whatsoever as to how they're consuming the hours (and how much they should pay for their debt later on).
So it would be useful if we can detect which students are the ones that don't have enough hours and allow the user to set either the rate that they should pay those hours for or simply registering how much should they pay for that debt.
Proposed approach
Tech considerations
studentId
hours
rate
(which could also be custom) thought about usingHour
here but since I want to be able to set a custom rate it might not be enough