Skip to content

[Bug][SubscriptionBilling]: Multiple Issues with Usage-Based Billing in Subscription Billing#7299

Open
miljance wants to merge 1 commit intomicrosoft:mainfrom
miljance:SBUsageBasedBillingFixes
Open

[Bug][SubscriptionBilling]: Multiple Issues with Usage-Based Billing in Subscription Billing#7299
miljance wants to merge 1 commit intomicrosoft:mainfrom
miljance:SBUsageBasedBillingFixes

Conversation

@miljance
Copy link
Contributor

@miljance miljance commented Mar 20, 2026

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

  • Billing accuracy for usage-based import files with unit prices
  • Correct handling of multi-currency usage data
  • Prevention of infinite credit memo loops
  • Full fidelity of archived subscription line documents

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

@miljance miljance requested a review from a team as a code owner March 20, 2026 15:08
@github-actions github-actions bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][SubscriptionBilling]: Multiple Issues with Usage-Based Billing in Subscription Billing

1 participant