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

fix: Force Fetching updates on Subscriptions #42221

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

ruthra-kumar
Copy link
Member

@ruthra-kumar ruthra-kumar commented Jul 8, 2024

Issue

Post this refactor, Fetch Subscription Updates creates Invoices only if the Current Invoice Start / End date matches the current date. For old subscriptions, this also resets these values to the current periods' start and end dates without creating any pending invoices.

Consider the below subscription,

Subscription Start Date 1st Jan
Subscription End Date 31 Dec
Plan Interval 1 Month

and current date is 2nd March

When 'Fetch Subscription Updates' is triggered,

Current behavior:

No Invoices are created for Jan and Feb and current_invoice_start and current_invoice_end date are updated to the latest month - March

Expected behavior:

Invoice for January should be created and the current_invoice_start and current_invoice_end should be updated to February. Upon triggering 'Fetch Subscription Updated' again, the same should happen for February. Triggering it again, should not create any invoices as the current period - March, is not over.

Fix

Adding a new Action button Force-Fetch Subscription Updates. This will have the expected behavior stated above, without allowing the scheduled job to create invoices for old subscriptions on its own.

Screenshot from 2024-08-13 14-54-19

Internal Ref: 13453

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Jul 8, 2024
@david-loe
Copy link

I would love to see this merged!

@ruthra-kumar
Copy link
Member Author

ruthra-kumar commented Aug 9, 2024

Backgroud Job

create_subscription_process runs every day. So, any old subscription with current_invoice_start and current_invoice_end still lower than current date will have it's Invoice created by the job and it will keep creating invoice daily till the current_invoice_start and current_invoice_end are within the current period.

This behavior is unwanted and was the reason for the original refactor in #30963

Maybe a different approach is required.

@ruthra-kumar ruthra-kumar changed the title fix: 'Fetch Subscription Updates' action for Subscription fix: Force Fetching updates on old subscriptions Aug 13, 2024
@ruthra-kumar
Copy link
Member Author

ruthra-kumar commented Aug 13, 2024

Maybe a different approach is required.

A new action button Force-Fetch Subscription Updates is added to achieve the intended effect without affecting the background job behavior.

@ruthra-kumar ruthra-kumar marked this pull request as ready for review August 13, 2024 10:36
@ruthra-kumar ruthra-kumar removed the needs-tests This PR needs automated unit-tests. label Aug 13, 2024
@ruthra-kumar ruthra-kumar changed the title fix: Force Fetching updates on old subscriptions fix: Force Fetching updates on Subscriptions Aug 13, 2024
@ruthra-kumar ruthra-kumar merged commit 7eb811c into frappe:develop Aug 13, 2024
19 checks passed
ruthra-kumar added a commit that referenced this pull request Aug 13, 2024
…-42221

fix: Force Fetching updates on Subscriptions (backport #42221)
ruthra-kumar added a commit that referenced this pull request Aug 13, 2024
…-42221

fix: Force Fetching updates on Subscriptions (backport #42221)
@david-loe
Copy link

david-loe commented Aug 14, 2024

some how the price of the resulting invoices is higher/lower than it should be, depending on the distance of the subscription period to the current date. A strange margin is added.

Start Date: 16th June
Interval: 1 Month
Price of Subscriotion: 80€

Create 2 Invoices with new force action

Invoice#1: 154,67€
Invoice#2: 72,26€
grafik

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

Successfully merging this pull request may close these issues.

2 participants