Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -184,9 +184,15 @@ report 11564 "SR G/L Acc Sheet Foreign Curr"
else
BalAccType := '';

FcyAcyAmt := "Source Currency Amount";
FcyAcyBalance := FcyAcyBalance + "Source Currency Amount";
Exrate := CalcExrate("Source Currency Amount", Amount, "G/L Account"."Source Currency Code");
if ("Source Currency Code" <> '') and ("Source Currency Code" = "G/L Account"."Source Currency Code") then begin
Comment thread
neeleshsinghal marked this conversation as resolved.
Outdated
Comment thread
neeleshsinghal marked this conversation as resolved.
Outdated
FcyAcyAmt := "Source Currency Amount";
FcyAcyBalance := FcyAcyBalance + "Source Currency Amount";
Exrate := CalcExrate("Source Currency Amount", Amount, "G/L Account"."Source Currency Code");
end else begin
FcyAcyAmt := 0;
Exrate := 0;
end;

OnAfterOnAfterGetRecord("G/L Account", "G/L Entry", FcyAcyAmt, FcyAcyBalance, Exrate);
end;

Expand Down
75 changes: 75 additions & 0 deletions src/Layers/CH/Tests/Local/TestGLAccSheetReports.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,81 @@ codeunit 144035 "Test G/L Acc Sheet Reports"
LibraryVariableStorage.AssertEmpty();
end;

[Test]
Comment thread
neeleshsinghal marked this conversation as resolved.
Outdated
[HandlerFunctions('GLAccSheetFCYReqPageHandler,GenJournalBatchesPageHandler')]
[Scope('OnPrem')]
procedure GLSheetForeignCurrExcludesMismatchedCurrencyEntries()
var
GenJournalTemplate: Record "Gen. Journal Template";
GLAccount: Record "G/L Account";
BalGLAccount: Record "G/L Account";
GenJournalLine: Record "Gen. Journal Line";
GLAccountSourceCurrency: Record "G/L Account Source Currency";
GLEntry: Record "G/L Entry";
CurrencyCode: Code[10];
OtherCurrencyCode: Code[10];
begin
// [FEATURE] [SR G/L Acc Sheet Foreign Curr]
// [SCENARIO 642513] Report 11564 must not mix amounts posted in a currency other than the
// G/L Account's Source Currency Code (including LCY-originated entries) into the foreign currency totals.
Initialize();

// [GIVEN] G/L Account set up for "Multiple Currencies" source currency posting with two registered currencies.
LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
GenJournalTemplate.Validate(Type, GenJournalTemplate.Type::General);
GenJournalTemplate.Modify(true);

CurrencyCode := LibraryERM.CreateCurrencyWithExchangeRate(WorkDate(), LibraryRandom.RandDec(100, 2), LibraryRandom.RandDec(100, 2));
OtherCurrencyCode := 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);
GLAccount.SetRange("No.", GLAccount."No.");
GLAccount.SetRange("Date Filter", WorkDate(), WorkDate());

GLAccountSourceCurrency.Init();
GLAccountSourceCurrency."G/L Account No." := GLAccount."No.";
GLAccountSourceCurrency."Currency Code" := CurrencyCode;
GLAccountSourceCurrency.Insert();

GLAccountSourceCurrency.Init();
GLAccountSourceCurrency."G/L Account No." := GLAccount."No.";
GLAccountSourceCurrency."Currency Code" := OtherCurrencyCode;
GLAccountSourceCurrency.Insert();

LibraryERM.CreateGLAccount(BalGLAccount);

// [GIVEN] An entry posted in "CurrencyCode" ...
Comment thread
neeleshsinghal marked this conversation as resolved.
Outdated
CreateGenJournalLine(GenJournalLine, GLAccount,
GenJournalLine."Bal. Account Type"::"G/L Account", BalGLAccount."No.", LibraryRandom.RandIntInRange(1000, 2000), CurrencyCode);
LibraryERM.PostGeneralJnlLine(GenJournalLine);

// [GIVEN] ... and another entry posted in "OtherCurrencyCode" to the same G/L Account.
Comment thread
neeleshsinghal marked this conversation as resolved.
Outdated
CreateGenJournalLine(GenJournalLine, GLAccount,
GenJournalLine."Bal. Account Type"::"G/L Account", BalGLAccount."No.", LibraryRandom.RandIntInRange(1000, 2000), OtherCurrencyCode);
LibraryERM.PostGeneralJnlLine(GenJournalLine);

// [WHEN] Run report 11564 "SR G/L Acc Sheet Foreign Curr"
RunSRGLAccSheetForeignCurrReport(GLAccount);

// [THEN] Neither entry is attributed to the G/L Account's (blank) Source Currency Code, so the
// foreign currency amount/balance columns must not mix amounts from the two different currencies.
LibraryReportDataset.LoadDataSetFile();
GLEntry.SetRange("G/L Account No.", GLAccount."No.");
GLEntry.FindSet();
repeat
LibraryReportDataset.Reset();
LibraryReportDataset.SetRange('No_GLAccount', GLAccount."No.");
LibraryReportDataset.SetRange('DocumentNo_GLEntry', GLEntry."Document No.");
LibraryReportDataset.GetNextRow();
LibraryReportDataset.AssertCurrentRowValueEquals('FcyAcyAmt', 0);
LibraryReportDataset.AssertCurrentRowValueEquals('GLEntryFcyAcyBalance', 0);
until GLEntry.Next() = 0;
end;

local procedure Initialize()
var
GenJnlTemplate: Record "Gen. Journal Template";
Expand Down
Loading