[SubscriptionBilling]Flexible Subscription Billing: Pause Billing and Support Quantity 0 for Usage-Based Contracts#6712
Conversation
…s.git into SBPauseSubscription
samra-singhammer
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Same comments as for the UnitPrice and NewSalesLineQuantity
| end; | ||
|
|
||
| [Test] | ||
| procedure TestBillingProposalWithZeroQuantity() |
There was a problem hiding this comment.
It should also test if Next Billing Date is set properly in the subscription line
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