feat: change the calculations #4198
Merged
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
Progressive billing credits were being distributed across all invoice fees, regardless of whether a fee belonged to the same charge as the progressive billing invoice.
Description
This PR updates Credits::ProgressiveBillingService so that credits from a progressive billing invoice are only applied to matching fees on the target invoice (same charge_id/context), instead of being spread across all fees.
This change was needed so that when we apply the credits from the wallet, we need to know the remaining fee, removing the progressive billing part
This issue would be more evident if we had multiple wallets, and some of them only applied to specific fees, the amount we need to take would not be correct (because the calculations would be affected by the progressive billing )