My application deals with user payments. In the company, this user has the following status:
- compliant (user payed all debts so far)
- overdue/default (user registered for 3 months minimum and has hasn't payed at least 1 debt)
- inactive (user is registered for less than 3 months and hasn't payed any debt)
How is the best way to deal with those rules in multiple places (and rules) inside the application?
Do I need a field like status_id
and a cron to update this every hour?
No status_id
field and write the SQL rule in every query that needs to show the status?
Load a User
model and call a ->status()
method that has the rule? In this case, how can I show "totals", like: We have 3000 overdue users, 15000 inactive users etc...
This is giving me headaches for months and I really need help haha. We currently have a solution but it's too complex to deal with it. As it seems to be something common within apps that deal with payment, there's must be a simplier way to do this :P
Thanks!
Notes
- Application has currently 90.000 users
- We need this info in real-time.
- This info is used in reports to generate chars.
- This info is showed inside the user profile.
- This info is showed in listings.
- Users are notified when a user change between those status (like, "you have debts" when user enters in "overdue").
- This info is not managed by application users.
- The status need to be tracked.