Skip to content
Merged
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 @@ -24,7 +24,9 @@ codeunit 31246 "FA General Report CZF"
if FixedAsset.FindSet() then
repeat
if FADepreciationBook.Get(FixedAsset."No.", DeprBookCode) then
if FixedAsset."Tax Deprec. Group Code CZF" <> FADepreciationBook."Tax Deprec. Group Code CZF" then begin
if (FixedAsset."Tax Deprec. Group Code CZF" <> FADepreciationBook."Tax Deprec. Group Code CZF") and
(FADepreciationBook."Tax Deprec. Group Code CZF" <> '')
then begin
FixedAsset."Tax Deprec. Group Code CZF" := FADepreciationBook."Tax Deprec. Group Code CZF";
FixedAsset.Modify();
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,88 @@ codeunit 148087 "Fixed Assets CZF"
GLEntry.TestField("G/L Account No.", FAExtendedPostingGroupCZF."Sales Acc. On Disp. (Gain)");
end;

[Test]
procedure SetFATaxDeprGroupDoesNotClearTaxDepreciationGroupWhenDepreciationBookTaxDepGroupIsBlank()
var
FASetup: Record "FA Setup";
FixedAsset: Record "Fixed Asset";
FADepreciationBook: Record "FA Depreciation Book";
TaxDepreciationGroupCZF: Record "Tax Depreciation Group CZF";
FAGeneralReportCZF: Codeunit "FA General Report CZF";
OriginalTaxDepGroupCode: Code[20];
begin
// [SCENARIO] SetFATaxDeprGroup does not clear Tax Deprec. Group Code CZF on Fixed Asset
// when FA Depreciation Book has blank Tax Deprec. Group Code CZF.

Initialize();
FASetup.Get();

// [GIVEN] Fixed Asset and FA Depreciation Book with Tax Deprec. Group Code CZF are created.
CreateFixedAsset(FixedAsset);
CreateTaxDepreciationGroupCZF(TaxDepreciationGroupCZF, TaxDepreciationGroupCZF."Depreciation Type"::"Straight-line");
CreateFADepreciationBook(
FADepreciationBook, FixedAsset."No.",
FASetup."Tax Depreciation Book CZF", TaxDepreciationGroupCZF.Code, true,
FADepreciationBook."Depreciation Method"::"Straight-Line");
FixedAsset.Validate("Tax Deprec. Group Code CZF", TaxDepreciationGroupCZF.Code);
FixedAsset.Modify(true);
OriginalTaxDepGroupCode := FixedAsset."Tax Deprec. Group Code CZF";

// [GIVEN] FA Depreciation Book Tax Deprec. Group Code CZF is blank.
FADepreciationBook."Tax Deprec. Group Code CZF" := ''; // Without validation because validation set the Fixed Asset Tax Deprec. Group Code CZF to blank.
FADepreciationBook.Modify(true);

// [WHEN] SetFATaxDeprGroup is called.
FixedAsset.SetRange("No.", FixedAsset."No.");
FAGeneralReportCZF.SetFATaxDeprGroup(FixedAsset, FADepreciationBook."Depreciation Book Code");

// [THEN] Tax Deprec. Group Code CZF on Fixed Asset remains unchanged.
FixedAsset.Get(FixedAsset."No.");
FixedAsset.TestField("Tax Deprec. Group Code CZF", OriginalTaxDepGroupCode);
end;

[Test]
procedure SetFATaxDeprGroupUpdatesTaxDepreciationGroupWhenDepreciationBookTaxDepGroupIsDifferentAndNotBlank()
var
FASetup: Record "FA Setup";
FixedAsset: Record "Fixed Asset";
FADepreciationBook: Record "FA Depreciation Book";
TaxDepreciationGroupCZF: Record "Tax Depreciation Group CZF";
NewTaxDepreciationGroupCZF: Record "Tax Depreciation Group CZF";
FAGeneralReportCZF: Codeunit "FA General Report CZF";
NewTaxDepGroupCode: Code[20];
begin
// [SCENARIO] SetFATaxDeprGroup updates Tax Deprec. Group Code CZF on Fixed Asset
// when FA Depreciation Book has a different non-blank Tax Deprec. Group Code CZF.

Initialize();
FASetup.Get();

// [GIVEN] Fixed Asset and FA Depreciation Book with initial Tax Deprec. Group Code CZF are created.
CreateFixedAsset(FixedAsset);
CreateTaxDepreciationGroupCZF(TaxDepreciationGroupCZF, TaxDepreciationGroupCZF."Depreciation Type"::"Straight-line");
CreateFADepreciationBook(
FADepreciationBook, FixedAsset."No.",
FASetup."Tax Depreciation Book CZF", TaxDepreciationGroupCZF.Code, true,
FADepreciationBook."Depreciation Method"::"Straight-Line");
FixedAsset.Validate("Tax Deprec. Group Code CZF", TaxDepreciationGroupCZF.Code);
FixedAsset.Modify(true);

// [GIVEN] FA Depreciation Book has another non-blank Tax Deprec. Group Code CZF.
CreateTaxDepreciationGroupCZF(NewTaxDepreciationGroupCZF, NewTaxDepreciationGroupCZF."Depreciation Type"::"Declining-Balance");
NewTaxDepGroupCode := NewTaxDepreciationGroupCZF.Code;
FADepreciationBook."Tax Deprec. Group Code CZF" := NewTaxDepGroupCode; // Without validation because validation set the Fixed Asset Tax Deprec. Group Code CZF to new value.
FADepreciationBook.Modify(true);

// [WHEN] SetFATaxDeprGroup is called.
FixedAsset.SetRange("No.", FixedAsset."No.");
FAGeneralReportCZF.SetFATaxDeprGroup(FixedAsset, FADepreciationBook."Depreciation Book Code");

// [THEN] Tax Deprec. Group Code CZF on Fixed Asset is updated from FA Depreciation Book.
FixedAsset.Get(FixedAsset."No.");
FixedAsset.TestField("Tax Deprec. Group Code CZF", NewTaxDepGroupCode);
end;

local procedure CreateFixedAsset(var FixedAsset: Record "Fixed Asset")
begin
LibraryFixedAsset.CreateFixedAsset(FixedAsset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,70 @@ codeunit 134981 "ERM Fixed Assets Reports - II"
VerifyGroupTotalValue(AcquisitionCostTxt, Amount);
end;

[Test]
[Scope('OnPrem')]
procedure SetFAPostingGroupDoesNotClearFAPostingGroupWhenDepreciationBookPostingGroupIsBlank()
var
FAGenReport: Codeunit "FA General Report";
FixedAsset: Record "Fixed Asset";
FADepreciationBook: Record "FA Depreciation Book";
FAPostingGroupCode: Code[20];
begin
// [SCENARIO] SetFAPostingGroup does not clear FA Posting Group on Fixed Asset
// when related FA Depreciation Book has blank FA Posting Group.

// [GIVEN] Fixed Asset and related FA Depreciation Book exist, and FA Depreciation Book has blank FA Posting Group.
Initialize();
LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
CreateFADepreciationBook(FADepreciationBook, FixedAsset);
FAPostingGroupCode := FixedAsset."FA Posting Group";
FADepreciationBook.Validate("FA Posting Group", '');
FADepreciationBook.Modify(true);

// [WHEN] SetFAPostingGroup is called.
FixedAsset.SetRange("No.", FixedAsset."No.");
FAGenReport.SetFAPostingGroup(FixedAsset, FADepreciationBook."Depreciation Book Code");

// [THEN] FA Posting Group on Fixed Asset remains unchanged.
FixedAsset.Get(FixedAsset."No.");
FixedAsset.TestField("FA Posting Group", FAPostingGroupCode);
end;

[Test]
[Scope('OnPrem')]
procedure SetFAPostingGroupUpdatesFAPostingGroupWhenDepreciationBookPostingGroupIsDifferentAndNotBlank()
var
FAGenReport: Codeunit "FA General Report";
FixedAsset: Record "Fixed Asset";
FADepreciationBook: Record "FA Depreciation Book";
FAPostingGroup: Record "FA Posting Group";
NewFAPostingGroupCode: Code[20];
begin
// [SCENARIO] SetFAPostingGroup updates FA Posting Group on Fixed Asset
// when related FA Depreciation Book has a different non-blank FA Posting Group.

// [GIVEN] Fixed Asset and related FA Depreciation Book exist, and FA Depreciation Book has a different non-blank FA Posting Group.
Initialize();
LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
CreateFADepreciationBook(FADepreciationBook, FixedAsset);
LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
NewFAPostingGroupCode := FAPostingGroup.Code;
if NewFAPostingGroupCode = FixedAsset."FA Posting Group" then begin
LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
NewFAPostingGroupCode := FAPostingGroup.Code;
end;
FADepreciationBook.Validate("FA Posting Group", NewFAPostingGroupCode);
FADepreciationBook.Modify(true);

// [WHEN] SetFAPostingGroup is called.
FixedAsset.SetRange("No.", FixedAsset."No.");
FAGenReport.SetFAPostingGroup(FixedAsset, FADepreciationBook."Depreciation Book Code");

// [THEN] FA Posting Group on Fixed Asset is updated from FA Depreciation Book.
FixedAsset.Get(FixedAsset."No.");
FixedAsset.TestField("FA Posting Group", NewFAPostingGroupCode);
end;

[Test]
[HandlerFunctions('CalculateDepreciationRequestPageHandler,DepreciationCalcConfirmHandler')]
[Scope('OnPrem')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ codeunit 5626 "FA General Report"
if FA.Find('-') then
repeat
if FADeprBook.Get(FA."No.", DeprBookCode) then
if FA."FA Posting Group" <> FADeprBook."FA Posting Group" then begin
if (FA."FA Posting Group" <> FADeprBook."FA Posting Group") and (FADeprBook."FA Posting Group" <> '') then begin
FA."FA Posting Group" := FADeprBook."FA Posting Group";
FA.Modify();
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ codeunit 5626 "FA General Report"
if FA.Find('-') then
repeat
if FADeprBook.Get(FA."No.", DeprBookCode) then
if FA."FA Posting Group" <> FADeprBook."FA Posting Group" then begin
if (FA."FA Posting Group" <> FADeprBook."FA Posting Group") and (FADeprBook."FA Posting Group" <> '') then begin
FA."FA Posting Group" := FADeprBook."FA Posting Group";
FA.Modify();
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ codeunit 5626 "FA General Report"
if FA.Find('-') then
repeat
if FADeprBook.Get(FA."No.", DeprBookCode) then
if FA."FA Posting Group" <> FADeprBook."FA Posting Group" then begin
if (FA."FA Posting Group" <> FADeprBook."FA Posting Group") and (FADeprBook."FA Posting Group" <> '') then begin
FA."FA Posting Group" := FADeprBook."FA Posting Group";
FA.Modify();
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,70 @@ codeunit 134981 "ERM Fixed Assets Reports - II"
VerifyGroupTotalValue(AcquisitionCostTxt, Amount);
end;

[Test]
[Scope('OnPrem')]
procedure SetFAPostingGroupDoesNotClearFAPostingGroupWhenDepreciationBookPostingGroupIsBlank()
var
FAGenReport: Codeunit "FA General Report";
FixedAsset: Record "Fixed Asset";
FADepreciationBook: Record "FA Depreciation Book";
FAPostingGroupCode: Code[20];
begin
// [SCENARIO] SetFAPostingGroup does not clear FA Posting Group on Fixed Asset
// when related FA Depreciation Book has blank FA Posting Group.

// [GIVEN] Fixed Asset and related FA Depreciation Book exist, and FA Depreciation Book has blank FA Posting Group.
Initialize();
LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
CreateFADepreciationBook(FADepreciationBook, FixedAsset);
FAPostingGroupCode := FixedAsset."FA Posting Group";
FADepreciationBook.Validate("FA Posting Group", '');
FADepreciationBook.Modify(true);

// [WHEN] SetFAPostingGroup is called.
FixedAsset.SetRange("No.", FixedAsset."No.");
FAGenReport.SetFAPostingGroup(FixedAsset, FADepreciationBook."Depreciation Book Code");

// [THEN] FA Posting Group on Fixed Asset remains unchanged.
FixedAsset.Get(FixedAsset."No.");
FixedAsset.TestField("FA Posting Group", FAPostingGroupCode);
end;

[Test]
[Scope('OnPrem')]
procedure SetFAPostingGroupUpdatesFAPostingGroupWhenDepreciationBookPostingGroupIsDifferentAndNotBlank()
var
FAGenReport: Codeunit "FA General Report";
FixedAsset: Record "Fixed Asset";
FADepreciationBook: Record "FA Depreciation Book";
FAPostingGroup: Record "FA Posting Group";
NewFAPostingGroupCode: Code[20];
begin
// [SCENARIO] SetFAPostingGroup updates FA Posting Group on Fixed Asset
// when related FA Depreciation Book has a different non-blank FA Posting Group.

// [GIVEN] Fixed Asset and related FA Depreciation Book exist, and FA Depreciation Book has a different non-blank FA Posting Group.
Initialize();
LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
CreateFADepreciationBook(FADepreciationBook, FixedAsset);
LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
NewFAPostingGroupCode := FAPostingGroup.Code;
if NewFAPostingGroupCode = FixedAsset."FA Posting Group" then begin
LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
NewFAPostingGroupCode := FAPostingGroup.Code;
end;
FADepreciationBook.Validate("FA Posting Group", NewFAPostingGroupCode);
FADepreciationBook.Modify(true);

// [WHEN] SetFAPostingGroup is called.
FixedAsset.SetRange("No.", FixedAsset."No.");
FAGenReport.SetFAPostingGroup(FixedAsset, FADepreciationBook."Depreciation Book Code");

// [THEN] FA Posting Group on Fixed Asset is updated from FA Depreciation Book.
FixedAsset.Get(FixedAsset."No.");
FixedAsset.TestField("FA Posting Group", NewFAPostingGroupCode);
end;

[Test]
[HandlerFunctions('CalculateDepreciationRequestPageHandler,MessageHandler')]
[Scope('OnPrem')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ codeunit 5626 "FA General Report"
if FA.Find('-') then
repeat
if FADeprBook.Get(FA."No.", DeprBookCode) then
if FA."FA Posting Group" <> FADeprBook."FA Posting Group" then begin
if (FA."FA Posting Group" <> FADeprBook."FA Posting Group") and (FADeprBook."FA Posting Group" <> '') then begin
FA."FA Posting Group" := FADeprBook."FA Posting Group";
FA.Modify();
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,70 @@ codeunit 134981 "ERM Fixed Assets Reports - II"
VerifyGroupTotalValue(AcquisitionCostTxt, Amount);
end;

[Test]
[Scope('OnPrem')]
procedure SetFAPostingGroupDoesNotClearFAPostingGroupWhenDepreciationBookPostingGroupIsBlank()
var
FAGenReport: Codeunit "FA General Report";
FixedAsset: Record "Fixed Asset";
FADepreciationBook: Record "FA Depreciation Book";
FAPostingGroupCode: Code[20];
begin
// [SCENARIO] SetFAPostingGroup does not clear FA Posting Group on Fixed Asset
// when related FA Depreciation Book has blank FA Posting Group.

// [GIVEN] Fixed Asset and related FA Depreciation Book exist, and FA Depreciation Book has blank FA Posting Group.
Initialize();
LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
CreateFADepreciationBook(FADepreciationBook, FixedAsset);
FAPostingGroupCode := FixedAsset."FA Posting Group";
FADepreciationBook.Validate("FA Posting Group", '');
FADepreciationBook.Modify(true);

// [WHEN] SetFAPostingGroup is called.
FixedAsset.SetRange("No.", FixedAsset."No.");
FAGenReport.SetFAPostingGroup(FixedAsset, FADepreciationBook."Depreciation Book Code");

// [THEN] FA Posting Group on Fixed Asset remains unchanged.
FixedAsset.Get(FixedAsset."No.");
FixedAsset.TestField("FA Posting Group", FAPostingGroupCode);
end;

[Test]
[Scope('OnPrem')]
procedure SetFAPostingGroupUpdatesFAPostingGroupWhenDepreciationBookPostingGroupIsDifferentAndNotBlank()
var
FAGenReport: Codeunit "FA General Report";
FixedAsset: Record "Fixed Asset";
FADepreciationBook: Record "FA Depreciation Book";
FAPostingGroup: Record "FA Posting Group";
NewFAPostingGroupCode: Code[20];
begin
// [SCENARIO] SetFAPostingGroup updates FA Posting Group on Fixed Asset
// when related FA Depreciation Book has a different non-blank FA Posting Group.

// [GIVEN] Fixed Asset and related FA Depreciation Book exist, and FA Depreciation Book has a different non-blank FA Posting Group.
Initialize();
LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
CreateFADepreciationBook(FADepreciationBook, FixedAsset);
LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
NewFAPostingGroupCode := FAPostingGroup.Code;
if NewFAPostingGroupCode = FixedAsset."FA Posting Group" then begin
LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
NewFAPostingGroupCode := FAPostingGroup.Code;
end;
FADepreciationBook.Validate("FA Posting Group", NewFAPostingGroupCode);
FADepreciationBook.Modify(true);

// [WHEN] SetFAPostingGroup is called.
FixedAsset.SetRange("No.", FixedAsset."No.");
FAGenReport.SetFAPostingGroup(FixedAsset, FADepreciationBook."Depreciation Book Code");

// [THEN] FA Posting Group on Fixed Asset is updated from FA Depreciation Book.
FixedAsset.Get(FixedAsset."No.");
FixedAsset.TestField("FA Posting Group", NewFAPostingGroupCode);
end;

[Test]
[HandlerFunctions('CalculateDepreciationRequestPageHandler,DepreciationCalcConfirmHandler')]
[Scope('OnPrem')]
Expand Down
Loading