I am in the process of writing a web app to track expenses and which will be multiuser.
Everything is fine with a single expense, but I am struggling to find the best way to represent recurring expenses, i.e. expenses of the same amount and category that repeat regularly until cancelled.
I am thinking to model recurring expenses as an instance of a more generic
ExpenseGenerator which as properties has a starting date and a frequency pattern, which then will automatically create one or more
Expenses, beginning from the starting date of the generator.
Given that this approach is correct (if not, please suggest some other options), I am unsure about how to trigger the creation of the expenses. Should I create something like a cronjob that creates the new expense as soon as it occurs or check the generator status every time a user does the login?
Both the solutions have some concern point:
Am I going in the right direction or is there a more efficient approach to model recurring events and solve all these problems?