In order to support subscription automation we need to keep a 'subscription date' in the the system. In fact we keep the Initial Subscription date. This has been done by adding an 'Initial Subscription' field to the user's profile (via http://www.openvpms.org/admin/user/profile ). Note that this field is hidden from the user and ie either set manually by a 'store manager' or by the system when the user first buys a subscription. This field is declared as a date and is actually held by as an array containing the day, month and year.
We need the Initial Subscription date so that we can correctly set the expiry date, not to 12 months after the user purchases the subscription renewal, but rather to the anniversary of their initial purchase.
This is implemented by the 'Run Keygen' condition action code which sets the Subscription Date to the current date if it has not been previously set. Note that since this code is run when payment is received, the Subscription Date is set to the date on which payment was received for the first subscription - and not the date on which the order was placed.
The code can be found at http://www.openvpms.org/admin/store/ca/2/edit/actions