Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -804,21 +804,22 @@ table 8059 "Subscription Line"
end;

internal procedure UpdateTermUntilUsingExtensionTerm(): Boolean
var
PreviousTermUntil: Date;
begin
if (IsExtensionTermEmpty() or
(("Term Until" = 0D) and ("Subscription Line Start Date" = 0D))) then
if IsExtensionTermEmpty() or
(("Term Until" = 0D) and ("Subscription Line Start Date" = 0D))
then
exit(false);
if "Term Until" <> 0D then begin
if DateTimeManagement.IsLastDayOfMonth("Term until") then begin
"Term Until" := CalcDate("Extension Term", "Term Until");
DateTimeManagement.MoveDateToLastDayOfMonth("Term until");
end else
"Term Until" := CalcDate("Extension Term", "Term Until");
end else begin
"Term Until" := CalcDate("Extension Term", "Subscription Line Start Date");
if DateTimeManagement.IsLastDayOfMonth("Subscription Line Start Date") then
DateTimeManagement.MoveDateToLastDayOfMonth("Term until");
if "Term Until" <> 0D then
PreviousTermUntil := "Term Until"
else begin
PreviousTermUntil := "Subscription Line Start Date";
PreviousTermUntil := CalcDate('<-1D>', PreviousTermUntil);
end;
"Term Until" := CalcDate("Extension Term", PreviousTermUntil);
if DateTimeManagement.IsLastDayOfMonth(PreviousTermUntil) then
DateTimeManagement.MoveDateToLastDayOfMonth("Term until");
exit(true);
end;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,9 @@ codeunit 148157 "Service Object Test"
Item: Record Item;
SubscriptionHeader: Record "Subscription Header";
SubscriptionLine: Record "Subscription Line";
DateTimeManagement: Codeunit "Date Time Management";
ExpectedCancellationPossibleUntil: Date;
ExpectedTermUntil: Date;
begin
// [SCENARIO] When "Notice Period" is empty, the action "Update Service Dates" does not calculate "Cancellation possible until" and "Term until"

Expand All @@ -1524,7 +1527,7 @@ codeunit 148157 "Service Object Test"
SetupServiceObjectWithServiceCommitment(Item, SubscriptionHeader, false, false);
SubscriptionLine.SetRange("Subscription Header No.", SubscriptionHeader."No.");
SubscriptionLine.FindFirst();
SubscriptionLine.Validate("Subscription Line Start Date", CalcDate('<-CY>', Today()));
SubscriptionLine.Validate("Subscription Line Start Date", CalcDate('<-CM>', Today()));
SubscriptionLine.Validate("Cancellation possible until", CalcDate('<+1D>', SubscriptionLine."Subscription Line Start Date"));
Evaluate(SubscriptionLine."Extension Term", '<1Y>');
SubscriptionLine.Modify(false);
Expand All @@ -1533,8 +1536,10 @@ codeunit 148157 "Service Object Test"
SubscriptionHeader.UpdateServicesDates();

// [THEN] "Cancellation possible until" and "Term until" are not recalculated
Assert.AreEqual(SubscriptionLine."Cancellation possible until", SubscriptionLine."Cancellation possible until", 'Cancellation possible until should not be recalculated.');
Assert.AreEqual(SubscriptionLine."Term until", SubscriptionLine."Term until", 'Term until should not be recalculated.');
ExpectedTermUntil := SubscriptionLine."Term until";
ExpectedCancellationPossibleUntil := SubscriptionLine."Cancellation possible until";
Assert.AreEqual(ExpectedTermUntil, SubscriptionLine."Term until", 'Term until should not be recalculated.');
Assert.AreEqual(ExpectedCancellationPossibleUntil, SubscriptionLine."Cancellation possible until", 'Cancellation possible until should not be recalculated.');

// [WHEN] Run action Update Service Dates from Service Object when "Notice Period" is not empty
Evaluate(SubscriptionLine."Notice Period", '<1M>');
Expand All @@ -1544,8 +1549,14 @@ codeunit 148157 "Service Object Test"
SubscriptionLine.Get(SubscriptionLine."Entry No.");

// [THEN] "Cancellation possible until" and "Term until" are recalculated
Assert.AreEqual(CalcDate(SubscriptionLine."Notice Period", SubscriptionLine."Cancellation possible until"), SubscriptionLine."Term until", 'Term until should be recalculated.');
Assert.AreEqual(CalcDate('-' + Format(SubscriptionLine."Notice Period"), SubscriptionLine."Term until"), SubscriptionLine."Cancellation possible until", 'Cancellation possible until should be recalculated.');
ExpectedTermUntil := CalcDate(SubscriptionLine."Extension Term", SubscriptionLine."Subscription Line Start Date" - 1);
if DateTimeManagement.IsLastDayOfMonth(SubscriptionLine."Subscription Line Start Date" - 1) then
DateTimeManagement.MoveDateToLastDayOfMonth(ExpectedTermUntil);
ExpectedCancellationPossibleUntil := CalcDate('-' + Format(SubscriptionLine."Notice Period"), SubscriptionLine."Term until");
if DateTimeManagement.IsLastDayOfMonth(ExpectedTermUntil) then
DateTimeManagement.MoveDateToLastDayOfMonth(ExpectedCancellationPossibleUntil);
Assert.AreEqual(ExpectedTermUntil, SubscriptionLine."Term until", 'Term until should be recalculated.');
Assert.AreEqual(ExpectedCancellationPossibleUntil, SubscriptionLine."Cancellation possible until", 'Cancellation possible until should be recalculated.');
end;

#endregion Tests
Expand Down
Loading