Skip to content

Comments

[SubscriptionBilling]Flexible Subscription Billing: Pause Billing and Support Quantity 0 for Usage-Based Contracts#6712

Open
miljance wants to merge 3 commits intomicrosoft:mainfrom
miljance:SBPauseSubscription
Open

[SubscriptionBilling]Flexible Subscription Billing: Pause Billing and Support Quantity 0 for Usage-Based Contracts#6712
miljance wants to merge 3 commits intomicrosoft:mainfrom
miljance:SBPauseSubscription

Conversation

@miljance
Copy link
Contributor

@miljance miljance commented Feb 17, 2026

Summary

This pull request introduces several improvements related to handling zero quantities in subscription billing, ensuring more robust calculations and clearer user feedback. The main changes focus on preventing division by zero errors, refining user messages and validations, and simplifying code by removing unnecessary checks and procedures.

Work Item(s)

Fixes #6637

@miljance miljance requested a review from a team as a code owner February 17, 2026 10:43
@github-actions github-actions bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Feb 17, 2026
Copy link
Contributor

@samra-singhammer samra-singhammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Miljan, please check my comments. Let me know if you have any questions.

if UsageDataBilling.Rebilling or (UsageDataBilling."Usage Base Pricing" = Enum::"Usage Based Pricing"::"Usage Quantity") then
BillingLine."Service Object Quantity" := UsageDataBilling.Quantity;
BillingLine."Unit Price" := BillingLine.Amount / BillingLine."Service Object Quantity";
if BillingLine."Service Object Quantity" <> 0 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Unit Price be explicitly set to zero if Service Object Quantity is zero?

// Apply discount from Subscription Line
BillingLine.Amount := BaseAmount * (1 - ServiceCommitment."Discount %" / 100);
BillingLine."Unit Cost" := UsageDataBilling."Cost Amount" / UsageDataBilling.Quantity;
if UsageDataBilling.Quantity <> 0 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Unit Cost be explicitly set to zero if Quantity is zero?

NewSalesLineQuantity := UsageDataBilling.Quantity;
if NewSalesLineQuantity = 0 then begin
UsageDataBilling.SetFilter(Quantity, '<>0');
if UsageDataBilling.FindLast() then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no UsageDataBilling is found, NewSalesLineQuantity will remain 0, then Unit Price will be set to 0, LIne Discount will be set from Service commitment. Is that expected and desired?

NewSalesLineAmount := UsageDataBilling.Amount;
UsageDataBilling.FindLast();
if UsageDataBilling.Rebilling then
NewSalesLineQuantity := UsageDataBilling.Quantity;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to improve readability in how NewSalesLineQuantity is set. Perhaps use "case" syntax.

UsageDataBilling.FindLast();
if UsageDataBilling.Rebilling then
NewPurchaseLineQuantity := UsageDataBilling.Quantity;
if NewPurchaseLineQuantity = 0 then begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as for the UnitPrice and NewSalesLineQuantity

end;

[Test]
procedure TestBillingProposalWithZeroQuantity()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should also test if Next Billing Date is set properly in the subscription line

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.

[BC Idea][SubscriptionBilling]: Flexible Subscription Billing: Pause Billing and Support Quantity 0 for Usage-Based Contracts

2 participants