[Bug][SubscriptionBilling]: Multiple Issues with Usage-Based Billing in Subscription Billing#7299
Open
miljance wants to merge 1 commit intomicrosoft:mainfrom
Open
[Bug][SubscriptionBilling]: Multiple Issues with Usage-Based Billing in Subscription Billing#7299miljance wants to merge 1 commit intomicrosoft:mainfrom
miljance wants to merge 1 commit intomicrosoft:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Overview
This PR addresses four bugs in the Usage-Based Billing (UBB) feature within Subscription Billing, all of which could result in incorrect invoicing, duplicate billing, or data loss during document archival.
Changes
Bug 1 — Unit Price Calculation Failure
When import files supply unit prices instead of total amounts, the system previously failed to derive the missing values, producing zero-amount invoices. This fix adds logic to calculate quantity, unit price, or total amount from whichever values are available in the import data.
Bug 2 — Foreign Currency Handling
When usage data is denominated in a currency different from the local currency, amounts were calculated incorrectly with no validation or conversion applied. This fix introduces currency mismatch detection and applies proper currency conversion when processing usage data in non-local currencies.
Bug 3 — Credit Memo Duplication Loop
Posting a credit memo generated from negative usage amounts caused a duplicate billing line to be created, which would then trigger another identical credit memo on the next billing run — repeating indefinitely. This fix prevents duplicate billing lines from being created during credit memo posting.
Bug 4 — Archive Field Loss
Three UBB-related fields (
Usage Based Billing,Usage Based Pricing,Pricing Unit Cost Surcharge %) were not being transferred to the Sales Subscription Line Archive table, breaking document restoration. This fix ensures all UBB fields are correctly included in the archive.Impact
Code Review
Before being approved from Microsoft side I do expect the code review from @sit-zm and/or @samra-singhammer
Work Item(s)
Fixes #6972