Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ page 6969 "Approver View API"
SubPageLink = "Pending Approval By" = field("No."),
Status = filter("Pending Approval" | "Interim Approved");
}

part(travelRequestsPendingApproval; "Travel Requests API")
{
EntityName = 'travelRequest';
EntitySetName = 'travelRequests';
SubPageLink = "Approver User Id Filter" = field(SystemId),
Status = const(Released);
}
}
}
}
Expand Down
47 changes: 47 additions & 0 deletions src/Apps/W1/ExpenseAgent/app/src/APIs/EmployeesAPI.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ page 6917 "Employees API"
DataAccessIntent = ReadOnly;
SourceTable = Employee;
AboutText = 'Lists details about employees that can use the expense functionalities.';
Permissions = tabledata Traveler = r,
tabledata "Expense User" = r;

layout
{
Expand All @@ -41,6 +43,12 @@ page 6917 "Employees API"
{
Caption = 'Number';
}
field(isExpenseUser; Rec."Is Expense User")
{
Caption = 'Is Expense User';
Editable = false;
ToolTip = 'Specifies whether the employee is linked to an expense user.';
}
field(name; Rec.FullName())
{
Caption = 'Name';
Expand All @@ -64,13 +72,52 @@ page 6917 "Employees API"
ExpenseAgentAPIValidation.VerifyAgentAccess();
end;

trigger OnOpenPage()
begin
ApplyTravelRequestFilter();
end;

trigger OnAfterGetRecord()
begin
CompanyInformation.Get();

OrganizationName := CompanyInformation.Name;
end;

local procedure ApplyTravelRequestFilter()
var
EmployeeFilterRecord: Record Employee;
TravelRequestEmployees: Query "Travel Request Employees";
EmployeeFilter: TextBuilder;
TravelRequestSystemId: Guid;
OriginalFilterGroup: Integer;
begin
OriginalFilterGroup := Rec.FilterGroup(4);
if Rec.GetFilter("Travel Request SystemId Filter") <> '' then
TravelRequestSystemId := Rec.GetRangeMin("Travel Request SystemId Filter");
Rec.FilterGroup(OriginalFilterGroup);
if IsNullGuid(TravelRequestSystemId) then
exit;

TravelRequestEmployees.SetRange(travelRequestSystemId, TravelRequestSystemId);
TravelRequestEmployees.Open();
while TravelRequestEmployees.Read() do
if TravelRequestEmployees.employeeNo <> '' then begin
if EmployeeFilter.Length > 0 then
EmployeeFilter.Append('|');
EmployeeFilterRecord.SetRange("No.", TravelRequestEmployees.employeeNo);
EmployeeFilter.Append(EmployeeFilterRecord.GetFilter("No."));
end;
TravelRequestEmployees.Close();

OriginalFilterGroup := Rec.FilterGroup(2);
if EmployeeFilter.Length = 0 then
Rec.SetRange(SystemId, CreateGuid())
else
Rec.SetFilter("No.", EmployeeFilter.ToText());
Rec.FilterGroup(OriginalFilterGroup);
end;

var
CompanyInformation: Record "Company Information";
OrganizationName: Text[100];
Expand Down
13 changes: 13 additions & 0 deletions src/Apps/W1/ExpenseAgent/app/src/APIs/ExpenseReportsAPI.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,23 @@ page 6928 "Expense Reports API"
{
Caption = 'Travel Request No.';
}
field(travelRequestId; Rec."Travel Request SystemId")
{
Caption = 'Travel Request Id';
Editable = false;
}
field(spendRequestClose; Rec."Spend Request Close")
{
Caption = 'Travel Request Close';
}
part(travelRequest; "Travel Requests API")
{
Caption = 'Travel Request';
EntityName = 'travelRequest';
EntitySetName = 'travelRequests';
Multiplicity = ZeroOrOne;
SubPageLink = SystemId = field("Travel Request SystemId");
}
part(expenseReportLines; "Expense Report Lines API")
{
Caption = 'Expense Report Lines';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ page 6918 "Expense Users API"
SubPageLink = "Expense User No." = field("No.");
}

part(travelRequests; "Travel Requests API")
{
EntityName = 'travelRequest';
EntitySetName = 'travelRequests';
SubPageLink = "Requested By User Id Filter" = field(SystemId);
}

part(activityHistory; "Expense Activity Log API")
{
EntityName = 'expenseActivityLogEntry';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ page 7102 "Spend Request Details API"
SourceTable = "Spend Request Detail";
AboutText = 'Provides access to data from the Spend Request Detail table';
AutoSplitKey = true;
Permissions = tabledata "Spend Request Detail" = rimd,
tabledata "Spend Request" = rm;

layout
{
Expand Down
18 changes: 18 additions & 0 deletions src/Apps/W1/ExpenseAgent/app/src/APIs/SpendRequestsAPI.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ page 7099 "Spend Requests API"
ODataKeyFields = SystemId;
SourceTable = "Spend Request";
AboutText = 'Provides access to data from the Spend Request table';
Permissions = tabledata "Spend Request" = rimd,
tabledata "Spend Request Detail" = rmd,
tabledata "Spend Request To G/L Link" = rd;

layout
{
Expand All @@ -39,6 +42,7 @@ page 7099 "Spend Requests API"
field(requestedBy; Rec."Requested By")
{
Caption = 'Requested By';
ToolTip = 'Specifies the employee who created the request. For travel requests, this value can be set only when creating the request.';
}
field(status; Rec.Status)
{
Expand Down Expand Up @@ -166,4 +170,18 @@ page 7099 "Spend Requests API"
begin
ExpenseAgentAPIValidation.VerifyAgentAccess();
end;

trigger OnModifyRecord(): Boolean
begin
// Protect travel request ownership through the legacy endpoint.
if (Rec."Document Type" = Rec."Document Type"::"Travel Request") and
(Rec."Requested By" <> xRec."Requested By")
then
Rec.FieldError("Requested By", RequestedByCannotBeChangedErr);

exit(true);
end;

var
RequestedByCannotBeChangedErr: Label 'cannot be changed';
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ page 7135 "Travel Request Details API"
SourceTable = "Spend Request Detail";
AboutText = 'Provides access to data from the Travel Request Detail table';
AutoSplitKey = true;
Permissions = tabledata "Spend Request Detail" = rimd,
tabledata "Spend Request" = rm;

layout
{
Expand All @@ -36,18 +38,36 @@ page 7135 "Travel Request Details API"
field(travelRequestNo; Rec."Spend Request No.")
{
Caption = 'Travel Request No.';
ToolTip = 'Specifies the travel request for the detail line.';
Editable = false;
}
field(lineNo; Rec."Line No.")
{
Caption = 'Line No.';
}
field(type; Rec.Type)
{
Caption = 'Type';
ToolTip = 'Specifies the type of the travel request detail.';
}
field(expenseCategoryCode; Rec."Expense Category Code")
{
Caption = 'Expense Category Code';
ToolTip = 'Specifies the expense category for the travel request detail.';
}
field(description; Rec.Description)
{
Caption = 'Description';
}
field(currencyCode; Rec."Currency Code")
field(currencyCode; CurrencyCodeDisplay)
{
Caption = 'Currency Code';
ToolTip = 'Specifies the currency used for estimation. The local currency is represented by its currency code in the API.';

trigger OnValidate()
begin
Rec.Validate("Currency Code", CurrencyHelper.GetCurrencyCodeFromAPI(CurrencyCodeDisplay));
end;
}
field(expectedAmount; Rec."Expected Amount")
{
Expand Down Expand Up @@ -77,4 +97,23 @@ page 7135 "Travel Request Details API"
begin
ExpenseAgentAPIValidation.VerifyAgentAccess();
end;

trigger OnOpenPage()
begin
Rec.AddLoadFields("Currency Code");
end;

trigger OnAfterGetRecord()
begin
CurrencyCodeDisplay := CurrencyHelper.GetCurrencyCodeForAPI(Rec."Currency Code");
end;

trigger OnNewRecord(BelowxRec: Boolean)
begin
Clear(CurrencyCodeDisplay);
end;

var
CurrencyHelper: Codeunit "Expense API Currency Helper";
CurrencyCodeDisplay: Code[10];
}
Loading
Loading