Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription phase alignment issue for subscriptions with end date #182

Closed
2 of 3 tasks
remcotolsma opened this issue Jun 5, 2024 · 3 comments · Fixed by #183
Closed
2 of 3 tasks

Subscription phase alignment issue for subscriptions with end date #182

remcotolsma opened this issue Jun 5, 2024 · 3 comments · Fixed by #183

Comments

@remcotolsma
Copy link
Member

remcotolsma commented Jun 5, 2024

Through a customer we discovered a problem with subscription phase alignment for subscriptions with an end date.

Internal HelpScout tickets:

Discussed with @rvdsteege at @pronamic HQ, the solution consists of 3 parts.

  • Allow partial periods in subscription phase period creation
  • No longer use total periods in subscription alignment
  • Improve user interface in Gravity Forms subscription alignment settings

Allow partial periods in subscription phase period creation

Related code:

$end_date = $this->add_interval( $start_date );
if ( null !== $this->end_date && $end_date > $this->end_date ) {
return null;
}

	if ( null !== $this->end_date && $end_date > $this->end_date ) {
		// Should we check if start date is before $this->end_date?
		$end_date = $this->end_date;
	}

No longer use total periods in subscription alignment

Related code:

$alignment_interval = new SubscriptionInterval( 'P' . $alignment_difference->days . 'D' );
$alignment_phase = new self( $phase->get_subscription(), $start_date, $alignment_interval, $phase->get_amount() );
$alignment_phase->set_total_periods( 1 );
$alignment_phase->set_alignment_rate( $alignment_difference->days / $regular_difference->days );
// Remove one period from regular phase.
$total_periods = $phase->get_total_periods();
if ( null !== $total_periods ) {
$phase->set_total_periods( $total_periods - 1 );
}
$alignment_end_date = $alignment_phase->get_end_date();
if ( null === $alignment_end_date ) {
throw new \Exception( 'The align phase should always end because this phase exists for one period.' );
}
$phase->set_start_date( $alignment_end_date );

It would be easier to understand if we extend a possible regular phase end date with the alignment period/interval?

Improve user interface in Gravity Forms subscription alignment settings

Related code:

https://github.com/pronamic/wp-pronamic-pay-gravityforms/blob/325d139b0c88ae43647d639159e3c64551143369/views/html-admin-feed-settings.php#L805-L985

Scherm­afbeelding 2024-06-05 om 13 17 21

Suggested change in Dutch:

Betalingsdatum uitlijnen
☑️ Betalingsdatum uitlijnen inschakelen
Het is mogelijk om de eerst volgende betalingsdatum uit te lijnen op een vaste dag van de week, maand of jaar. Hiervoor wordt er een extra abonnementsfase toegevoegd aan het begin van het abonnement. Als het aantal perioden vast staat ingesteld krijg je er dus altijd 1 extra periode bij. Het af te rekenen bedrag voor deze uitlijningsfase kan naar rato worden berekend.

@remcotolsma
Copy link
Member Author

remcotolsma commented Jun 5, 2024

⚠️ 🚨 Another important addition: In the screenshot, the fixed periods settings is set to 2, which currently results in 1 period in the alignment phase and 1 period in the regular phase. After the proposed change it will result in 1 period in the alignment phase and 2 periods in the regular phase. This because we believe that this makes more sense? Otherwise the following entry/payment would result in only one alignment period:

Interval: 1 year
Fixed periods: 1
Alignment date: January 1
Entry date: December 15, 2024

This would make more sense?

  1. Alignment period: December 15, 2024 - December 31, 2024
  2. Regular period: January 1, 2025 - December 31, 2025

For this client we can change the fixed periods setting from 2 to 1, for other clients a changelog note?

@rvdsteege
Copy link
Member

Re-opening for "Improve user interface in Gravity Forms subscription alignment settings".

The name and description of the setting are already updated in pronamic/wp-pronamic-pay-gravityforms@df49d2d.

Scherm­afbeelding 2024-06-05 om 16 58 34

@remcotolsma
Copy link
Member Author

Closing this issue, moved the open task to the Pronamic Pay Gravity Forms repository:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants