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 @@ -328,7 +328,7 @@ report 11564 "SR G/L Acc Sheet Foreign Curr"
else
BalAccType := '';

if ("Currency Code" <> '') and ("Currency Code" = "G/L Account"."Source Currency Code") then begin
if IsGLAccountSourceCurrency("Currency Code") then begin
FcyAcyAmt := Amount;
FcyAcyBalance := FcyAcyBalance + Amount;
Exrate := CalcExrate(Amount, "Amount (LCY)", "Gen. Journal Line"."Currency Code");
Expand Down Expand Up @@ -610,6 +610,21 @@ report 11564 "SR G/L Acc Sheet Foreign Curr"
GenJourLine2.SetRange("Bal. Account Type");
end;

local procedure IsGLAccountSourceCurrency(CurrencyCode: Code[10]): Boolean
var
GLAccountSourceCurrency: Record "G/L Account Source Currency";
begin
if CurrencyCode = '' then
exit(false);

if CurrencyCode = "G/L Account"."Source Currency Code" then
exit(true);

GLAccountSourceCurrency.SetRange("G/L Account No.", "G/L Account"."No.");
GLAccountSourceCurrency.SetRange("Currency Code", CurrencyCode);
exit(not GLAccountSourceCurrency.IsEmpty());
end;

[IntegrationEvent(false, false)]
procedure OnAfterOnAfterGetRecord(var GLAccount: Record "G/L Account"; var GLEntry: Record "G/L Entry"; var FcyAcyAmt: Decimal; var FcyAcyBalance: Decimal; var Exrate: Decimal)
begin
Expand Down
45 changes: 45 additions & 0 deletions src/Layers/CH/Tests/Local/TestGLAccSheetReports.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,51 @@ codeunit 144035 "Test G/L Acc Sheet Reports"
// VerifyGLAccForeignCurrReportValues(GLAccount, CurrencyCode, DocumentNo, AmountFCY) - skip verifivcation
end;

[Test]
[HandlerFunctions('GLAccSheetForeignCurrReqPageHandler')]
[Scope('OnPrem')]
procedure GLSheetForeignCurrMultipleCurrenciesIncludesRegisteredCurrency()
var
GLAccount: Record "G/L Account";
BalGLAccount: Record "G/L Account";
GLAccountSourceCurrency: Record "G/L Account Source Currency";
GenJournalLine: Record "Gen. Journal Line";
AmountFCY: Decimal;
CurrencyCode: Code[10];
begin
// [SCENARIO] Report 11564 includes FCY amount for multiple-currencies account when currency is registered.
Initialize();

// [GIVEN] Multiple-currency G/L account with registered source currency.
AmountFCY := LibraryRandom.RandIntInRange(1000, 2000);
CurrencyCode := LibraryERM.CreateCurrencyWithExchangeRate(WorkDate(), LibraryRandom.RandDec(100, 2), LibraryRandom.RandDec(100, 2));

LibraryERM.CreateGLAccount(GLAccount);
GLAccount.Validate("Account Type", GLAccount."Account Type"::Posting);
GLAccount.Validate("Income/Balance", GLAccount."Income/Balance"::"Balance Sheet");
GLAccount.Validate("Source Currency Posting", GLAccount."Source Currency Posting"::"Multiple Currencies");
GLAccount.Modify(true);

GLAccountSourceCurrency.InsertRecord(GLAccount."No.", CurrencyCode);

LibraryERM.CreateGLAccount(BalGLAccount);
CreateGenJournalLine(
GenJournalLine, GLAccount, GenJournalLine."Bal. Account Type"::"G/L Account", BalGLAccount."No.", AmountFCY, CurrencyCode);

// [WHEN] Run report.
LibraryVariableStorage.Enqueue(GLAccount."No.");
RunSRGLAccSheetForeignCurrReport(GLAccount);

// [THEN] Temporary entry keeps FCY values.
LibraryReportDataset.LoadDataSetFile();
LibraryReportDataset.SetRange('No_GLAccount', GLAccount."No.");
LibraryReportDataset.SetRange('DocumentNo_GenJournalLine', GenJournalLine."Document No.");
LibraryReportDataset.GetNextRow();
LibraryReportDataset.AssertCurrentRowValueEquals('GenJournalLineFcyAcyAmt', Abs(GenJournalLine.Amount));
LibraryReportDataset.AssertCurrentRowValueNotEquals('GenJournalLineExrate', 0);
LibraryVariableStorage.AssertEmpty();
end;

[Test]
[HandlerFunctions('GLAccSheetFCYWithDateFilterRPH')]
procedure GLSheetForeignCurrNoErrorWhenSourceCurrCodeBlank()
Expand Down
Loading