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

Monthly recurring payments at end of month have various problems #551

Open
jonasc opened this issue Oct 5, 2024 · 4 comments
Open

Monthly recurring payments at end of month have various problems #551

jonasc opened this issue Oct 5, 2024 · 4 comments

Comments

@jonasc
Copy link

jonasc commented Oct 5, 2024

Problem

Create a new subscription repeated every month.

Select next payment to be on 2024-10-31. On the calendar this is show on the first of the month except the next:

  • 2024-10-01
  • (nothing in 2024-11)
  • 2024-12-01
  • 2025-01-01
  • and on every first of the month onwards

Select next payment to be on 2024-10-30. On the calendar this is show on:

  • 2024-10-30
  • 2024-11-30
  • 2024-12-30
  • 2025-01-30
  • (nothing in 2025-02)
  • 2025-03-02 (here the date shifts by the two days missing in 2025-02 toward the 30th)
  • 2025-04-02
  • and on every second of the month onwards, no changes in 2026-02 because it seems that it now assumes the recurring date is the 2nd of each month

Suggestion:

Check the actual day of month for monthly recurring payments and if a month doesn't have that day (because it's shorter) then take the last day of this month instead. However it should still keep the original day of month for all months that have this day.

@ellite
Copy link
Owner

ellite commented Oct 5, 2024

The calendar page uses PHP's built-in function strtotime() to calculate the next month. PHP is doing all the work behind the scenes using its own internal logic.

strtotime("+1 month", ...)

PHP handles how months and dates interact, including leap years and varying month lengths (28, 30, or 31 days), so there are no manual date calculations in the code.

The strtotime() function is designed to handle these date shifts accurately and efficiently. This means I'm not manually calculating dates, but rather relying on PHP to perform the operation.

I know most subscriptions don't rollover like this. I have some that do, and some that don't. And I decided to not overcomplicate.

@jonasc
Copy link
Author

jonasc commented Oct 6, 2024

I understand, thanks for the explanation. I guess then for myself, as a workaround, I will just move the date in Wallos to the 28th of the month.

I know most subscriptions don't rollover like this. I have some that do, and some that don't.

Isn't a subscription that rolls over like this essentially a subscription that renews every 30 (or 31) days instead of one that renews every month? Because I also have a subscription like this which due to renewing every 30 days gradually shifts towards earlier days of the month.

@ellite
Copy link
Owner

ellite commented Oct 6, 2024

Yes, usually 30 days, I believe. I see it mostly on insurances.
Please keep this issue open so I can revisit it when I have some time.
Probably the easy way is not the best way.
And since we can select 30 Days as the subscription frequency, probably 1 month should be exactly as you described.

The issue is that there's only the next_payment_date field. So if I calculate from January 30th to February 28th, I have no way to then know that it should go back to March 30th.
Maybe I should store a start date as well, so we always know the original day.

When I have some time, I'll give it a thought.

@jonasc
Copy link
Author

jonasc commented Oct 6, 2024

I think the problem might also be that when I enter the subscription, I only set the "next payment" date. If I do this in November, I would naturally enter the 30th and it wouldn't become the 31st for December.
So it would probably need some more logic, e.g. only selecting on which day of month the payment is due (and 31 being equal to "last day" or having 1 to 31 and additionally "last day") instead of selecting a specific date?
Well, these are just my thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants