fix: Recurring fee not displayed on invoices after upgrade #3012
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Steps to reproduce the issue:
Create a recurring metric;
Create a plan with a charge linked to the recurring metric - the charge should be:
Create a subscription with a start date in the past and send an event in the past (e.g. 1 December) -> you receive a fee.created webhook;
Duplicate the original plan and only modify the price of the charge (higher price);
Trigger an upgrade of the existing subscription by assigning the new plan;
Mark the fee in step 3 as succeeded via POST api/v1/fees/:lago_id
Terminate the subscription -> the fee is not included in the end-of-period invoice.
Expected behaviour: the fee should be included in the end-of-period invoice, even if the original Lago subscription to which it belongs is no longer active.
Description
This change fetches all subscriptions with status active or terminated of a given organization with a matching external id to invoice their paid in advance fees.