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: Recurring fee not displayed on invoices after upgrade #3012

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ancorcruz
Copy link
Contributor

@ancorcruz ancorcruz commented Dec 30, 2024

Context

Steps to reproduce the issue:

  1. Create a recurring metric;

  2. Create a plan with a charge linked to the recurring metric - the charge should be:

  • prorated = true;
  • pay_in_advance = true;
  • invoiceable = false;
  • regroup_paid_fees = invoice;
  1. 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;

  2. Duplicate the original plan and only modify the price of the charge (higher price);

  3. Trigger an upgrade of the existing subscription by assigning the new plan;

  4. Mark the fee in step 3 as succeeded via POST api/v1/fees/:lago_id

  5. 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.

@ancorcruz ancorcruz requested a review from nudded December 30, 2024 16:55
@ancorcruz ancorcruz self-assigned this Dec 30, 2024
@ancorcruz ancorcruz added the 🐞 Bug Something isn't working label Dec 30, 2024
Recurring fee not displayed on invoices after upgrade
... including all invoices with the same external_id. This ensure if
there is any pending fee to be invoiced it will be.

Be aware of, subscriptions external_id does not have unique constraints,
even we are scoping the subscriptions search to the organzation... Could
two customers of the same organization have the same external_id in
different invoices?
This change only fixed the issue partially, all other use cases like end
of billing period were not handled as expected
finds all terminated and active subscriptions with the same external_id
to invoice advance fees belonging to them.
@ancorcruz ancorcruz force-pushed the fix/recurring-fee-not-invoiced branch from d9a9421 to d145065 Compare January 2, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants