I want to add subscription based invoicing to my application. The invoicing itself is not part of this question as that is already in place.
As multiple customers will use this functionaity I want to setup subscriptionrules in a very flexible way. The biggest challange for me is to allow different periods (intervals) for each rule (one per rule). F.e. when you look at recurring appointments in MS Outlook (see attached image - Dutch) you get an idea what I'm aiming for.
My challange is how to efficiently store all these settings into a table (datamodal) and to determine which rule(s) need to be invoiced based on the current date. After a rule is invoiced the last-invoiced-date will be set for the rule.
- How to store these subscriptionrules efficiently in a database?
- How to determine which rule(s) must be executed (invoiced) based on a given day?
- How to make sure a rule is never skipped (f.e. when application isn't used for some days/weeks))
If a rule should have been executed a few times (based on last-invoiced-date, period and current date) all 'missed' executions must be all executed anyhow afterwards.
Any simple source-examples are very welcome as is any advice on the issue at hand.