pronamic / wp-pay-core

Core components for the WordPress payment processing library. This library is used in the WordPress plugin Pronamic Pay: https://www.pronamicpay.com/, but also allows other plugin developers to set up a payment plugin.
https://www.wp-pay.org/
GNU General Public License v3.0
27 stars 3 forks source link

Calculating periods created is wrong with a subscription phase with an end date #187

Open remcotolsma opened 2 months ago

remcotolsma commented 2 months ago

https://github.com/pronamic/wp-pay-core/blob/bd197f4b1d3ddd2947c8d0a210171c2e7482bac7/src/Subscriptions/SubscriptionPhase.php#L293-L312

The next payment date can go far beyond the end date of a subscription phase.

Scherm­afbeelding 2024-06-19 om 12 25 03

Should we add something like this?

if ( null !== $this->end_date ) {
    $next_date = \min( $next_date, $this->end_date );
}

Probably also rename the variable $next_date to $anchor_date or $pointer_date?

CC @rvdsteege

rvdsteege commented 2 months ago

Should we add something like this?

As discussed at HQ, I think that that would be correct to fix the calculation.