Skip to content

[Bug][SubscriptionBilling]: Subscription line end date incorrectly set when subsequent term is defined on the subscription package#8513

Merged
djukicmilica merged 1 commit into
microsoft:mainfrom
miljance:SBEndDateNotSetWhenSubsequentTermIsUsed
Jun 8, 2026
Merged

[Bug][SubscriptionBilling]: Subscription line end date incorrectly set when subsequent term is defined on the subscription package#8513
djukicmilica merged 1 commit into
microsoft:mainfrom
miljance:SBEndDateNotSetWhenSubsequentTermIsUsed

Conversation

@miljance
Copy link
Copy Markdown
Contributor

@miljance miljance commented Jun 7, 2026

What & why

When a Subscription Line has a Subsequent Term (Extension Term) defined, the contract auto-renews indefinitely, so no fixed End Date should be stored.

  • CalculateServiceEndDate: exit early when Extension Term is set
  • CalculateTermUntilDate: when End Date is 0D and Extension Term is set, derive Term Until from Initial Term (or Notice Period as fallback) instead of falling through to the Notice Period path unconditionally; mirrors the logic already encoded in the GetTermUntilDate/GetCancellationPossibleUntilDate test helpers
  • Update CheckClearTerminationPeriods: End Date is intentionally 0D when Subsequent Term is defined
  • Update VerifySubscriptionLineDates: expect End Date = 0D when Extension Term is set on the Subscription Line
  • Add CheckSubscriptionLineEndDateNotSetWhenSubsequentTermIsUsed (unit test on CalculateServiceEndDate) and the corresponding integration test via sales order posting in SalesServiceCommitmentTest

Linked work

Fixes #8428

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome (required ΓÇö be specific: scenarios, commands, screenshots for UI changes)

Risk & compatibility

Low risk. The change affects two internal procedures (CalculateServiceEndDate, CalculateTermUntilDate) that are not part of the public API surface.

Existing data: Subscription Lines already in the database are not affected ΓÇö the fix only applies at creation/calculation time. Lines that were created before this fix with an incorrect End Date will keep that value until manually cleared or recalculated via "Update Subscription Line Dates".

Behavior change: For Subscription Lines with both an Initial Term and a Subsequent Term:

End Date is no longer auto-populated (was Start + Initial Term − 1D, now blank). This is the intended correction.
Term Until and Cancellation Possible Until continue to be calculated correctly from the Initial Term, so invoicing and cancellation logic is unaffected.
No behavior change for Subscription Lines without a Subsequent Term ΓÇö CalculateServiceEndDate and CalculateTermUntilDate follow the same paths as before.

Fixes AB#637991

… Term is used

When a Subscription Line has a Subsequent Term (Extension Term) defined,
the contract auto-renews indefinitely, so no fixed End Date should be stored.

- CalculateServiceEndDate: exit early when Extension Term is set
- CalculateTermUntilDate: when End Date is 0D and Extension Term is set,
  derive Term Until from Initial Term (or Notice Period as fallback) instead
  of falling through to the Notice Period path unconditionally; mirrors the
  logic already encoded in the GetTermUntilDate/GetCancellationPossibleUntilDate
  test helpers
- Update CheckClearTerminationPeriods: End Date is intentionally 0D when
  Subsequent Term is defined
- Update VerifySubscriptionLineDates: expect End Date = 0D when Extension Term
  is set on the Subscription Line
- Add CheckSubscriptionLineEndDateNotSetWhenSubsequentTermIsUsed (unit test on
  CalculateServiceEndDate) and the corresponding integration test via sales
  order posting in SalesServiceCommitmentTest

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@miljance miljance requested a review from a team as a code owner June 7, 2026 20:43
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork needs-approval Workflow runs require maintainer approval to start and removed needs-approval Workflow runs require maintainer approval to start labels Jun 7, 2026
@djukicmilica djukicmilica added the Linked Issue is linked to a Azure Boards work item label Jun 8, 2026
@djukicmilica djukicmilica enabled auto-merge (squash) June 8, 2026 09:03
@github-actions github-actions Bot added this to the Version 29.0 milestone Jun 8, 2026
@JesperSchulz JesperSchulz added the Finance GitHub request for Finance area label Jun 8, 2026
@djukicmilica djukicmilica merged commit f2ec192 into microsoft:main Jun 8, 2026
49 of 50 checks passed
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 Finance GitHub request for Finance area 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.

[Bug][SubscriptionBilling]: Subscription line end date incorrectly set when subsequent term is defined on the subscription package

4 participants