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 @@ -56,7 +56,7 @@ codeunit 6983 "Create Expense Report"
else
Error('');

ExpenseReportHeader := GetExpenseReportHeader(ExpenseReportNo, Expense."Expense User No.", Expense."Currency Code", Expense."VAT Bus. Posting Group");
ExpenseReportHeader := GetExpenseReportHeader(ExpenseReportNo, Expense."Expense User No.", Expense."VAT Bus. Posting Group");
LoopThruExpenseToAddInReport(Expense, ExpenseReportHeader);
ShowExpenseReport(ExpenseReportHeader, ExpenseReportNo <> '');
end;
Expand All @@ -81,7 +81,7 @@ codeunit 6983 "Create Expense Report"
Page.Run(Page::"Expense Report", ExpenseReportHeader);
end;

local procedure GetExpenseReportHeader(ExpenseReportNo: Code[20]; ExpenseUserNo: Code[20]; CurrencyCode: Code[10]; VATBusPostingGroup: Code[20]): Record "Expense Report Header"
local procedure GetExpenseReportHeader(ExpenseReportNo: Code[20]; ExpenseUserNo: Code[20]; VATBusPostingGroup: Code[20]): Record "Expense Report Header"
var
ExpenseReportHeader: Record "Expense Report Header";
begin
Expand All @@ -90,7 +90,6 @@ codeunit 6983 "Create Expense Report"

ExpenseReportHeader.Init();
ExpenseReportHeader.Validate("Expense User No.", ExpenseUserNo);
ExpenseReportHeader.Validate("Reimbursement Currency Code", CurrencyCode);
ExpenseReportHeader.Validate("VAT Bus. Posting Group", VATBusPostingGroup);
ExpenseReportHeader.Insert(true);

Expand Down
38 changes: 38 additions & 0 deletions src/Apps/W1/ExpenseAgent/test/src/ExpenseTestII.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,44 @@ codeunit 148309 "Expense Test II"
StrSubstNo(ValueMustBeEqualErr, ExpenseReportLine.FieldCaption("Expense Detail Required"), ExpenseCategory."Expense Detail Required", ExpenseReportLine.TableCaption()));
end;

[Test]
[HandlerFunctions('ConfirmHandlerNo,AddExpensesToExpenseReportModalPageHandler')]
procedure CreateExpenseReportUsesLocalCurrencyForForeignCurrencyExpense()
var
Expense: Record Expense;
ExpenseReportHeader: Record "Expense Report Header";
ExpenseReportLine: Record "Expense Report Line";
ExpenseCategory: Record "Expense Category";
ExpenseUser: Record "Expense User";
CreateExpenseReport: Codeunit "Create Expense Report";
CurrencyCode: Code[10];
begin
// [SCENARIO 647169] Verify that a report created from a foreign currency expense uses local currency for reimbursement.
Initialize();

// [GIVEN] Create a released expense in a foreign currency.
CurrencyCode := LibraryERM.CreateCurrencyWithExchangeRate(WorkDate(), LibraryRandom.RandDec(10, 2), LibraryRandom.RandDec(10, 2));
LibraryExpense.CreateExpenseUser(ExpenseUser);
LibraryExpense.CreateExpenseCategory(ExpenseCategory, ExpenseCategory."Reimbursement Type"::"Employee Paid", ExpenseCategory."Expense Detail Required"::" ");
LibraryExpense.CreateExpense(Expense, ExpenseUser."No.", ExpenseCategory.Code, '', '', true, CurrencyCode, 100);
Expense.PerformManualRelease();

// [GIVEN] Select a new expense report.
LibraryVariableStorage.Enqueue(false);

// [WHEN] Create the expense report from the expense.
Expense.SetRange("No.", Expense."No.");
CreateExpenseReport.AddExpensesToReport(Expense);

// [THEN] The report uses local currency for reimbursement and retains the foreign currency on the line.
Expense.Get(Expense."No.");
ExpenseReportHeader.Get(Expense."Expense Report No.");
ExpenseReportHeader.TestField("Reimbursement Currency Code", '');
ExpenseReportLine.SetRange("Document No.", ExpenseReportHeader."No.");
ExpenseReportLine.FindFirst();
ExpenseReportLine.TestField("Expense Currency Code", CurrencyCode);
end;

[Test]
procedure ReimbursementTypeMustBeUpdatedFromPaymentMethodCodeInExpense()
var
Expand Down
Loading