Describe the issue
When a Customer Subscription Contract has Harmonized Billing enabled and the "Next Billing To" date is stale (older than the
current billing period), running "Create Billing Proposal" on the Recurring Billing page (Page 8067) causes an infinite loop.
The process never completes and holds an Exclusive lock on the Customer Subscription Contract table indefinitely.
Root cause
In Codeunit 8062 "Billing Proposal", method CalculateBillingPeriod contains a while loop:
while (BillingPeriodEnd < BillingDate) and (...)
do
BillingPeriodEnd := CalculateNextBillingToDateForServiceCommitment(
ServiceCommitment, BillingPeriodEnd + 1);
Inside CalculateNextBillingToDateForServiceCommitment, when Harmonized Billing is enabled, HarmonizeNextBillingTo caps
NextBillingToDate to CustomerContract."Next Billing To":
if NextBillingToDate < CustomerContractNextBillingTo then exit;
NextBillingToDate := CustomerContractNextBillingTo; // caps backwards
When CustomerContract."Next Billing To" is a stale past date (e.g. 1/31/2026) and BillingDate is 5/28/2026:
- Every iteration calculates a natural
NextBillingToDate (2/28, 3/31, ...)
HarmonizeNextBillingTo caps it back to 1/31/2026
BillingPeriodEnd never advances → infinite loop
Verified via AL Debugger: BillingPeriodEnd = 01/31/2026 on every consecutive iteration, never changes.
Suggested fix (one possible approach)
In CalculateNextBillingToDateForServiceCommitment, skip harmonization
when "Next Billing To" is older than BillingFromDate:
if ServiceCommitment.IsPartnerCustomer() then begin
CustomerContract.Get(ServiceCommitment."Subscription Contract No.");
if CustomerContract.IsContractTypeSetAsHarmonizedBilling() then
if CustomerContract."Next Billing To" >= BillingFromDate then
HarmonizeNextBillingTo(CustomerContract."Next Billing To", NextBillingToDate);
end;
Note: This is a proposed direction. The correct fix may need to consider
harmonization behavior in catch-up scenarios.
Expected behavior
Billing proposal is created successfully even when billing is behind by more than one period.
Steps to reproduce
- Create a Customer Subscription Contract with Harmonized Billing enabled (set
Billing Base Date, Default Billing Rhythm: 1M)
- Add subscription lines with
Billing Rhythm: 1M and Next Billing Date more than one month in the past
- Ensure
"Next Billing To" on the contract is in the past (this happens when invoices were never posted after a previous
billing proposal, or when billing is skipped for one or more periods)
- Open Recurring Billing (Page 8067), set Billing Date to today, click "Create Billing Proposal"
Result: Process runs indefinitely
Expected: Billing proposal created successfully
When does this happen in production?
- Billing proposal created but invoices never posted (proposal cleared)
- Billing skipped for one or more periods
- Initial setup where billing has never been run
Note: Annual (12M) contracts are not affected because CalculateNextToDate(12M, 1/1/2026) = 12/31/2026 already exceeds
any reasonable BillingDate, so the while loop never executes.
Version
Subscription Billing by Microsoft, version 28.0.46665.48632
Business Central SaaS Sandbox
Additional context
AL Debugger confirms BillingPeriodEnd is identical on consecutive iterations:
- Iteration 1:
BillingPeriodEnd = 01/31/2026, BillingFromDate = 02/01/2026
- Iteration 2:
BillingPeriodEnd = 01/31/2026, BillingFromDate = 02/01/2026
CustomerContract."Next Billing To" = 01/31/2026 (stale)
BillingDate = 05/28/2026
Database Locks page confirms Exclusive lock held on Customer Subscription Contract
for the entire duration with session never completing.
I will provide a fix for a bug
Describe the issue
When a Customer Subscription Contract has Harmonized Billing enabled and the "Next Billing To" date is stale (older than the
current billing period), running "Create Billing Proposal" on the Recurring Billing page (Page 8067) causes an infinite loop.
The process never completes and holds an Exclusive lock on the
Customer Subscription Contracttable indefinitely.Root cause
In
Codeunit 8062 "Billing Proposal", methodCalculateBillingPeriodcontains a while loop:Inside
CalculateNextBillingToDateForServiceCommitment, when Harmonized Billing is enabled,HarmonizeNextBillingTocapsNextBillingToDatetoCustomerContract."Next Billing To":When
CustomerContract."Next Billing To"is a stale past date (e.g.1/31/2026) andBillingDateis5/28/2026:NextBillingToDate(2/28, 3/31, ...)HarmonizeNextBillingTocaps it back to1/31/2026BillingPeriodEndnever advances → infinite loopVerified via AL Debugger:
BillingPeriodEnd=01/31/2026on every consecutive iteration, never changes.Suggested fix (one possible approach)
In
CalculateNextBillingToDateForServiceCommitment, skip harmonizationwhen
"Next Billing To"is older thanBillingFromDate:Note: This is a proposed direction. The correct fix may need to consider
harmonization behavior in catch-up scenarios.
Expected behavior
Billing proposal is created successfully even when billing is behind by more than one period.
Steps to reproduce
Billing Base Date,Default Billing Rhythm: 1M)Billing Rhythm: 1MandNext Billing Datemore than one month in the past"Next Billing To"on the contract is in the past (this happens when invoices were never posted after a previousbilling proposal, or when billing is skipped for one or more periods)
Result: Process runs indefinitely
Expected: Billing proposal created successfully
When does this happen in production?
Version
Subscription Billing by Microsoft, version 28.0.46665.48632
Business Central SaaS Sandbox
Additional context
AL Debugger confirms
BillingPeriodEndis identical on consecutive iterations:BillingPeriodEnd = 01/31/2026,BillingFromDate = 02/01/2026BillingPeriodEnd = 01/31/2026,BillingFromDate = 02/01/2026CustomerContract."Next Billing To" = 01/31/2026(stale)BillingDate = 05/28/2026Database Locks page confirms Exclusive lock held on
Customer Subscription Contractfor the entire duration with session never completing.
I will provide a fix for a bug