Skip to content
Draft
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 @@ -94,6 +94,16 @@ table 4812 "Intrastat Report Line"
Caption = 'Country/Region Code';
TableRelation = "Country/Region";
ToolTip = 'Specifies the country/region of the address.';
trigger OnValidate()
var
IntrastatReportMgt: Codeunit IntrastatReportManagement;
begin
if "Country/Region Code" = '' then begin
Validate("Intrastat Country/Region Code", '');
exit;
end;

Validate("Intrastat Country/Region Code", IntrastatReportMgt.GetIntrastatCodeFromCountryRegion("Country/Region Code"));
}
field(8; "Transaction Type"; Code[10])
{
Expand Down
25 changes: 25 additions & 0 deletions src/Apps/W1/Intrastat/test/src/IntrastatReportTest.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -4829,6 +4829,31 @@ codeunit 139550 "Intrastat Report Test"
Assert.AreEqual(TariffNo."No.", ItemTempl."Tariff No.", '');
end;

[Test]
procedure ManualIntrastatReportLineUsesIntrastatCode()
var
CountryRegion: array[2] of Record "Country/Region";
IntrastatReportLine: Record "Intrastat Report Line";
begin
// [SCENARIO 646599] Intrastat Country/Region Code is populated from the Country/Region's Intrastat Code when a line is added manually
Initialize();

// [GIVEN] Create Country/Region with a different Intrastat Code.
LibraryIntrastat.CreateCountryRegion(CountryRegion[1], true);
LibraryIntrastat.CreateCountryRegion(CountryRegion[2], true);
CountryRegion[1].Validate(CountryRegion[1]."Intrastat Code", CountryRegion[2].Code);
CountryRegion[1].Modify(true);

// [GIVEN] An Intrastat Report with a manually added line
LibraryIntrastat.CreateIntrastatReportLine(IntrastatReportLine);

// [WHEN] The Country/Region Code is validated on the line
IntrastatReportLine.Validate("Country/Region Code", CountryRegion[1].Code);

// [THEN] The Intrastat Country/Region Code inherits the Intrastat Code from the Country/Region
IntrastatReportLine.TestField("Intrastat Country/Region Code", CountryRegion[2].Code);
Comment thread
neeleshsinghal marked this conversation as resolved.
end;

local procedure Initialize()
var
LibraryERMCountryData: Codeunit "Library - ERM Country Data";
Expand Down
Loading