I have a case where when charges for a license are pro-rated, the billing should start at the beginning of the current month, not from the current date/time.
The only way I can think of to make that work is to add a drupal_alter() call just after line 173 of commerce_license_billing.rules.inc to allow another module to make a change to the time. It can pass in the line item to allow some logic around that.
Another solution might be to add an option to the rules action where you can choose between commonly used options for the pro-rating start date/time, such as "current month," "current day" etc.
For now I will patch my copy of the module to do what I need and wait and see if this feature will be accommodated, either with an alter hook or options to choose from in the rule action configuration.
Comments
Comment #1
teknocat commentedNote that it turns out I have to continue with beta 3 of this module in my project, as beta 4 causes a problem with commerce_price module. When commerce_price_wrapper_value() is called, it throws an error on line 843 about trying to call a method of a non-object. Reverting back to beta 3 resolves this. I will report this separately (if it hasn't been already), but thought I would also note it here. My solution to this particular issue for now was to add a call to drupal_alter after line 125 of commerce_license_billing.rules.inc as follows:
My module alters the time, setting it to the first day of the month, and now it pro-rates prices for me exactly the way I need it to.