Hello,
I’m trying to generate bills. for my app. I’d like to know where is the most suitable place for me to put this particular function.
Here are the scenarios:
A user can select a student and click somewhere from the profile a Generate Bill
button for him/her. A list of bills would also be generated automatically on the first day of the months.
My first thought would be putting it in the Bill
model as a class method, for e.g Bill::generate(student)
. But then, it got me thinking whether it’s a right place since the Bill
method has to interact with Student
and Enrollment
model (stores which package the student is currently subscribed to and it is also linked to another model that stores the fee).
So, my questions are:
- Where should I put the bill generator function.
- What are the best way for me to generate bills by bulk every month. Is it ok if I just use whenever gem and call the function or should I queue the task and run it in the background.
Thanks in advance.