Skip to content

[28.x] Subscription Billing] Infinite loop in CalculateBillingPeriod when HarmonizeNextBillingTo caps at stale "Next Billing To" date#9419

Draft
sanjmaurya wants to merge 2 commits into
microsoft:releases/28.xfrom
sanjmaurya:bugs/Bug-637042-28x-SubscriptionBillingInfiniteLoopCalculateBillingPeriodN2
Draft

[28.x] Subscription Billing] Infinite loop in CalculateBillingPeriod when HarmonizeNextBillingTo caps at stale "Next Billing To" date#9419
sanjmaurya wants to merge 2 commits into
microsoft:releases/28.xfrom
sanjmaurya:bugs/Bug-637042-28x-SubscriptionBillingInfiniteLoopCalculateBillingPeriodN2

Conversation

@sanjmaurya

@sanjmaurya sanjmaurya commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Bug 637042: [ALL-E][Subscription Billing] Infinite loop in CalculateBillingPeriod when HarmonizeNextBillingTo caps at stale "Next Billing To" date

Fixes AB#637042

Issue:- CalculateBillingPeriod in BillingProposal.Codeunit.al enters an infinite loop (hang / no response) when generating a billing proposal for a harmonized customer subscription contract whose "Next Billing To" date is stale (older than the current billing period being calculated).
Cause :- Root Cause
The while loop advances the billing period end date by repeatedly calling CalculateNextBillingToDateForServiceCommitment:

For a harmonized contract, CalculateNextBillingToDateForServiceCommitment calls HarmonizeNextBillingTo, which caps the computed date at CustomerContract."Next Billing To":

When the contract's "Next Billing To" is a stale date earlier than BillingDate, every iteration gets capped back to that same stale value. So BillingPeriodEnd never advances past it, the loop condition BillingPeriodEnd < BillingDate stays true forever, and the loop never terminates.
Solution
Add a progress guard that breaks the loop as soon as BillingPeriodEnd stops advancing (i.e., is capped to the same/earlier date). A PreviousBillingPeriodEnd tracker is introduced, and the loop only continues while BillingPeriodEnd > PreviousBillingPeriodEnd:

@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork Linked Issue is linked to a Azure Boards work item labels Jul 14, 2026
@github-actions github-actions Bot modified the milestone: Version 28.4 Jul 14, 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 Linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants