Commit 4e1d2b6
authored
[Subscription Billing]Calculating initial dates correctly (#6352)
<!-- Thank you for submitting a Pull Request. If you're new to
contributing to BCApps please read our pull request guideline below
* https://github.com/microsoft/BCApps/Contributing.md
-->
#### Summary <!-- Provide a general summary of your changes -->
This PR addresses two reported issues in Subscription Billing related to
incorrect or missing updates of subscription line dates (`Subscription
Line End Date` / `Service End Date`, `Term Until`, and `Cancellation
Possible Until`).
#### Fixed Issues
1. **Initial subscription dates not calculated correctly when
Subsequent/Extension Term is defined**
When posting Ship and Invoice from a Sales Order containing a
Subscription Item with both Initial Term and Subsequent Term filled, the
`Subscription Line Start Date` updated correctly, but `Service End Date`
and `Term Until` remained empty.
The root cause was logic that skipped initial end-date calculations when
a Subsequent/Extension Term existed.
Changes introduce a new internal procedure
`CalculateInitialSubscriptionDates()` in **Subscription Line** that
always calculates both `Service End Date` (via
`CalculateInitialServiceEndDate()`) and `Term Until` (via
`CalculateInitialTermUntilDate()`). Calls in **Sales Documents**,
**Create Subscription Line**, **Post Sub. Contract Renewal**, and
**Subscription Header** now use this consolidated procedure, ensuring
initial dates are set correctly regardless of Subsequent/Extension Term
presence.
2. **Cancellation Possible Until and Term Until not recalculated when
Service Start Date is modified**
On non-invoiced subscription lines (e.g., after "Extend Contract" or
manual edit), changing `Service Start Date` did not automatically update
`Cancellation Possible Until` or `Term Until`. The "Update Subscription
Line Dates" action also failed to update these fields.
The refactor ensures consistent date recalculation:
- `CalculateInitialTermUntilDate()` now prioritizes existing
`Subscription Line End Date` when set and always updates `Cancellation
Possible Until` via `UpdateCancellationPossibleUntil()`.
- Consolidated initial date calculation improves reliability when start
dates change before invoicing.
#### Additional Improvements
- Simplified and standardized the `Extension Term` tooltip across
multiple pages (e.g., Service Commitments, Planned Service Commitments,
Customer Contract Lines) by removing outdated references to conditional
end-date setting, reflecting the new always-calculate-initial behavior.
- Added propagation of `Renewal Term` to **Sub. Contr. Analysis Entry**
for better data consistency in contract analysis.
These changes improve reliability of automatic date calculations, reduce
manual corrections, and align behavior with expected subscription
lifecycle rules without affecting existing renewal logic for subsequent
periods.
Technical code review from @samra-singhammer or @sit-zm required prior
to approval by Microsoft.
#### Work Item(s) <!-- Add the issue number here after the #. The issue
needs to be open and approved. Submitting PRs with no linked issues or
unapproved issues is highly discouraged. -->
Fixes #6132
[AB#620493](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/620493)1 parent b4f4247 commit 4e1d2b6
24 files changed
Lines changed: 208 additions & 176 deletions
File tree
- src/Apps/W1/Subscription Billing
- App
- Billing/Codeunits
- Contract Renewal
- Codeunits
- Pages
- ContractAnalysis
- Customer Contracts/Pages
- Import
- Codeunits
- Pages
- Sales Service Commitments/Pages
- Service Commitments
- Pages
- Tables
- Service Objects/Tables
- Vendor Contracts/Pages
- Test
- Base
- Service Objects
- UBB
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
546 | | - | |
547 | | - | |
| 545 | + | |
548 | 546 | | |
549 | 547 | | |
550 | 548 | | |
| |||
src/Apps/W1/Subscription Billing/App/Contract Renewal/Codeunits/PostSubContractRenewal.Codeunit.al
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
| 110 | + | |
113 | 111 | | |
114 | 112 | | |
115 | 113 | | |
| |||
274 | 272 | | |
275 | 273 | | |
276 | 274 | | |
277 | | - | |
| 275 | + | |
278 | 276 | | |
279 | 277 | | |
280 | 278 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| 344 | + | |
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
| 389 | + | |
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | 121 | | |
123 | | - | |
124 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
0 commit comments