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

misc(invoice): Bypass aggregation queries when no event in period #2967

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

vincent-pochet
Copy link
Collaborator

Context

The current approach for generating a subscription invoice with charge fees is to perform one aggregation request per charge (and possibly per charge filter when defined) no matter the number of events received during the billing period.
For plans counting a lot of charges this could be very slow when many invoices are generated in parallel (on a 1st day of a month for example).

After some research, it appears that in many cases, most of the aggregation result for both charges or filters results in a zero fee as no event were received.

Description

The goal of this PR is to add a pre-check on events before performing the charge billing. It will detect the distinct event code received for a specific subscription during the billing period, and use this list to perform the aggregation only on charge having at least one event.

NOTE: this aggregation byepassing will not apply in in-advance or recurring billing as in these cases the aggregation result relies on more than the event received during the billing period.

@vincent-pochet vincent-pochet merged commit 930498c into main Dec 17, 2024
6 checks passed
@vincent-pochet vincent-pochet deleted the misc-received-event branch December 17, 2024 12:14
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

Successfully merging this pull request may close these issues.

2 participants