Page 9308 Purchase Invoices
- App
- Base Application
- Namespace
- Microsoft.Purchases.Document
- Versions
- 17-28
- Source table
- 38
Versions171819202122232425262728
Source29
Source in 29
src/Layers/W1/BaseApp/Purchases/Document/PurchaseInvoices.Page.al740 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Purchases.Document;
using Microsoft.EServices.EDocument;
using Microsoft.Finance.Dimension;
using Microsoft.Foundation.Attachment;
using Microsoft.Foundation.Reporting;
using Microsoft.Purchases.Comment;
using Microsoft.Purchases.History;
using Microsoft.Purchases.Posting;
using Microsoft.Purchases.Setup;
using Microsoft.Purchases.Vendor;
using Microsoft.Utilities;
using System.Automation;
using System.Environment.Configuration;
using System.Integration.PowerBI;
using System.Text;
using System.Threading;
page 9308 "Purchase Invoices"
{
AdditionalSearchTerms = 'Vendor Invoices, Procurement Invoices, Vendor Bills, Purchase Bills, Supplier Invoices, Acquisition Bills, Buying Invoices, Supplier Bill List, Invoice Purchase Log, Merchant Invoices, Trade Invoices';
ApplicationArea = Basic, Suite;
Caption = 'Purchase Invoices';
CardPageID = "Purchase Invoice";
DataCaptionFields = "Buy-from Vendor No.";
Editable = false;
PageType = List;
AboutTitle = 'About Purchase Invoices';
AboutText = 'Create, manage, and post purchase invoices to record vendor bills, track accounts payable, apply discounts, and update inventory and financial records for received items or services.';
QueryCategory = 'Purchase Invoices';
RefreshOnActivate = true;
SourceTable = "Purchase Header";
SourceTableView = where("Document Type" = const(Invoice));
UsageCategory = Lists;
layout
{
area(content)
{
repeater(Control1)
{
ShowCaption = false;
field("No."; Rec."No.")
{
ApplicationArea = All;
ToolTip = 'Specifies the number of the involved entry or record, according to the specified number series.';
}
field("Buy-from Vendor No."; Rec."Buy-from Vendor No.")
{
ApplicationArea = All;
ToolTip = 'Specifies the name of the vendor who delivered the items.';
}
field("Order Address Code"; Rec."Order Address Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Buy-from Vendor Name"; Rec."Buy-from Vendor Name")
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the name of the vendor who delivered the items.';
}
field("Vendor Authorization No."; Rec."Vendor Authorization No.")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Vendor Invoice No."; Rec."Vendor Invoice No.")
{
ApplicationArea = Basic, Suite;
}
field("Buy-from Post Code"; Rec."Buy-from Post Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Buy-from Country/Region Code"; Rec."Buy-from Country/Region Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Buy-from Contact"; Rec."Buy-from Contact")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Pay-to Vendor No."; Rec."Pay-to Vendor No.")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Pay-to Name"; Rec."Pay-to Name")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Pay-to Post Code"; Rec."Pay-to Post Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Pay-to Country/Region Code"; Rec."Pay-to Country/Region Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Pay-to Contact"; Rec."Pay-to Contact")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Ship-to Code"; Rec."Ship-to Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Ship-to Name"; Rec."Ship-to Name")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Ship-to Post Code"; Rec."Ship-to Post Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Ship-to Country/Region Code"; Rec."Ship-to Country/Region Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Ship-to Contact"; Rec."Ship-to Contact")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Posting Date"; Rec."Posting Date")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Shortcut Dimension 1 Code"; Rec."Shortcut Dimension 1 Code")
{
ApplicationArea = Dimensions;
Visible = false;
}
field("Shortcut Dimension 2 Code"; Rec."Shortcut Dimension 2 Code")
{
ApplicationArea = Dimensions;
Visible = false;
}
field("Location Code"; Rec."Location Code")
{
ApplicationArea = Location;
}
field("Purchaser Code"; Rec."Purchaser Code")
{
ApplicationArea = Suite;
Visible = false;
}
field("Assigned User ID"; Rec."Assigned User ID")
{
ApplicationArea = Basic, Suite;
}
field("Currency Code"; Rec."Currency Code")
{
ApplicationArea = Suite;
Visible = false;
}
field("Document Date"; Rec."Document Date")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field(Status; Rec.Status)
{
ApplicationArea = Basic, Suite;
Visible = false;
StyleExpr = StatusStyleTxt;
}
field("Payment Terms Code"; Rec."Payment Terms Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Due Date"; Rec."Due Date")
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies when the invoice is due.';
Visible = false;
}
field("Payment Discount %"; Rec."Payment Discount %")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Payment Method Code"; Rec."Payment Method Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Shipment Method Code"; Rec."Shipment Method Code")
{
ApplicationArea = Suite;
Visible = false;
}
field("Requested Receipt Date"; Rec."Requested Receipt Date")
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the date that you want the vendor to deliver your order. The field is used to calculate the latest date you can order, as follows: requested receipt date - lead time calculation = order date. If you do not need delivery on a specific date, you can leave the field blank.';
Visible = false;
}
field("Your Reference"; Rec."Your Reference")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Job Queue Status"; Rec."Job Queue Status")
{
ApplicationArea = All;
Style = Unfavorable;
StyleExpr = Rec."Job Queue Status" = Rec."Job Queue Status"::ERROR;
ToolTip = 'Specifies the status of a job queue entry that handles the posting of purchase invoices.';
Visible = JobQueueActive;
trigger OnDrillDown()
var
JobQueueEntry: Record "Job Queue Entry";
begin
if Rec."Job Queue Status" = Rec."Job Queue Status"::" " then
exit;
JobQueueEntry.ShowStatusMsg(Rec."Job Queue Entry ID");
end;
}
field(Amount; Rec.Amount)
{
ApplicationArea = Basic, Suite;
}
field("Amount Including VAT"; Rec."Amount Including VAT")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
}
}
area(factboxes)
{
part("Attached Documents List"; "Doc. Attachment List Factbox")
{
ApplicationArea = All;
Caption = 'Documents';
UpdatePropagation = Both;
SubPageLink = "Table ID" = const(Database::"Purchase Header"),
"No." = field("No."),
"Document Type" = field("Document Type");
}
part(PowerBIEmbeddedReportPart; "Power BI Embedded Report Part")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
part(IncomingDocAttachFactBox; "Incoming Doc. Attach. FactBox")
{
ApplicationArea = Basic, Suite;
ShowFilter = false;
}
part(Control1901138007; "Vendor Details FactBox")
{
ApplicationArea = Basic, Suite;
SubPageLink = "No." = field("Buy-from Vendor No."),
"Date Filter" = field("Date Filter");
}
systempart(Control1900383207; Links)
{
ApplicationArea = RecordLinks;
Visible = false;
}
systempart(Control1905767507; Notes)
{
ApplicationArea = Notes;
}
}
}
actions
{
area(navigation)
{
group("&Invoice")
{
Caption = '&Invoice';
Image = Invoice;
action(PurchaseStatistics)
{
ApplicationArea = Basic, Suite;
Caption = 'Statistics';
Enabled = Rec."No." <> '';
Image = Statistics;
ShortCutKey = 'F7';
Visible = true;
ToolTip = 'View statistical information, such as the value of posted entries, for the record.';
RunObject = Page "Purchase Statistics";
RunPageOnRec = true;
}
action(VendorStatistics)
{
ApplicationArea = Basic, Suite;
Caption = 'Vendor Statistics';
Enabled = Rec."Buy-from Vendor No." <> '';
Image = Statistics;
RunObject = Page "Vendor Statistics";
RunPageLink = "No." = field("Buy-from Vendor No."),
"Date Filter" = field("Date Filter");
ToolTip = 'View statistical information, such as the value of posted entries, for the buy-from vendor on the purchase document.';
}
action("Co&mments")
{
ApplicationArea = Comments;
Caption = 'Co&mments';
Image = ViewComments;
RunObject = Page "Purch. Comment Sheet";
RunPageLink = "Document Type" = field("Document Type"),
"No." = field("No."),
"Document Line No." = const(0);
ToolTip = 'View or add comments for the record.';
}
action(Dimensions)
{
AccessByPermission = TableData Dimension = R;
ApplicationArea = Dimensions;
Caption = 'Dimensions';
Image = Dimensions;
ShortCutKey = 'Alt+D';
ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';
trigger OnAction()
begin
Rec.ShowDocDim();
end;
}
}
}
area(processing)
{
group(Invoice)
{
Caption = 'Invoice';
action(Approvals)
{
AccessByPermission = TableData "Approval Entry" = R;
ApplicationArea = Suite;
Caption = 'Approvals';
Image = Approvals;
ToolTip = 'View a list of the records that are waiting to be approved. For example, you can see who requested the record to be approved, when it was sent, and when it is due to be approved.';
trigger OnAction()
var
ApprovalsMgmt: Codeunit "Approvals Mgmt.";
begin
ApprovalsMgmt.OpenApprovalsPurchase(Rec);
end;
}
action(Vendor)
{
ApplicationArea = Basic, Suite;
Caption = 'Vendor';
Image = Vendor;
RunObject = Page "Vendor Card";
RunPageLink = "No." = field("Buy-from Vendor No."),
"Date Filter" = field("Date Filter");
Scope = Repeater;
ShortCutKey = 'Shift+F7';
ToolTip = 'View or edit detailed information about the vendor on the purchase document.';
}
}
group(Action7)
{
Caption = 'Release';
Image = ReleaseDoc;
action(Release)
{
ApplicationArea = Basic, Suite;
Caption = 'Re&lease';
Image = ReleaseDoc;
ShortCutKey = 'Ctrl+F9';
ToolTip = 'Release the document to the next stage of processing. You must reopen the document before you can make changes to it.';
trigger OnAction()
var
PurchaseHeader: Record "Purchase Header";
begin
CurrPage.SetSelectionFilter(PurchaseHeader);
Rec.PerformManualRelease(PurchaseHeader);
end;
}
action(Reopen)
{
ApplicationArea = Basic, Suite;
Caption = 'Re&open';
Image = ReOpen;
ToolTip = 'Reopen the document to change it after it has been approved. Approved documents have the Released status and must be opened before they can be changed';
trigger OnAction()
var
PurchaseHeader: Record "Purchase Header";
begin
CurrPage.SetSelectionFilter(PurchaseHeader);
Rec.PerformManualReopen(PurchaseHeader);
end;
}
}
group("Request Approval")
{
Caption = 'Request Approval';
Image = "Action";
action(SendApprovalRequest)
{
ApplicationArea = Basic, Suite;
Caption = 'Send A&pproval Request';
Enabled = not OpenApprovalEntriesExist and CanRequestApprovalForFlow;
Image = SendApprovalRequest;
ToolTip = 'Request approval of the document.';
trigger OnAction()
var
ApprovalsMgmt: Codeunit "Approvals Mgmt.";
begin
if ApprovalsMgmt.CheckPurchaseApprovalPossible(Rec) then
ApprovalsMgmt.OnSendPurchaseDocForApproval(Rec);
end;
}
action(CancelApprovalRequest)
{
ApplicationArea = Basic, Suite;
Caption = 'Cancel Approval Re&quest';
Enabled = CanCancelApprovalForRecord or CanCancelApprovalForFlow;
Image = CancelApprovalRequest;
ToolTip = 'Cancel the approval request.';
trigger OnAction()
var
ApprovalsMgmt: Codeunit "Approvals Mgmt.";
WorkflowWebhookManagement: Codeunit "Workflow Webhook Management";
begin
ApprovalsMgmt.OnCancelPurchaseApprovalRequest(Rec);
WorkflowWebhookManagement.FindAndCancel(Rec.RecordId);
end;
}
}
group("P&osting")
{
Caption = 'P&osting';
Image = Post;
action(PostSelected)
{
ApplicationArea = Basic, Suite;
Caption = 'P&ost';
Image = PostOrder;
ShortCutKey = 'F9';
ToolTip = 'Finalize the document or journal by posting the amounts and quantities to the related accounts in your company books.';
trigger OnAction()
var
PurchaseHeader: Record "Purchase Header";
PurchaseBatchPostMgt: Codeunit "Purchase Batch Post Mgt.";
begin
CurrPage.SetSelectionFilter(PurchaseHeader);
if PurchaseHeader.Count > 1 then begin
PurchaseHeader.FindSet();
repeat
VerifyTotal(PurchaseHeader);
until PurchaseHeader.Next() = 0;
PurchaseBatchPostMgt.RunWithUI(PurchaseHeader, Rec.Count(), ReadyToPostQst);
end else begin
VerifyTotal(Rec);
Post(CODEUNIT::"Purch.-Post (Yes/No)");
end;
end;
}
action(Preview)
{
ApplicationArea = Basic, Suite;
Caption = 'Preview Posting';
Image = ViewPostedOrder;
ShortCutKey = 'Ctrl+Alt+F9';
ToolTip = 'Review the different types of entries that will be created when you post the document or journal.';
trigger OnAction()
var
SelectedPurchaseHeader: Record "Purchase Header";
PurchPostYesNo: Codeunit "Purch.-Post (Yes/No)";
begin
CurrPage.SetSelectionFilter(SelectedPurchaseHeader);
PurchPostYesNo.MessageIfPostingPreviewMultipleDocuments(SelectedPurchaseHeader, Rec."No.");
PurchPostYesNo.Preview(Rec);
end;
}
action(TestReport)
{
ApplicationArea = Basic, Suite;
Caption = 'Test Report';
Ellipsis = true;
Image = TestReport;
ToolTip = 'View a test report so that you can find and correct any errors before you perform the actual posting of the journal or document.';
trigger OnAction()
begin
ReportPrint.PrintPurchHeader(Rec);
end;
}
action(PostAndPrint)
{
ApplicationArea = Basic, Suite;
Caption = 'Post and &Print';
Image = PostPrint;
ShortCutKey = 'Shift+F9';
ToolTip = 'Finalize and print the document or journal. The values and quantities are posted to the related accounts.';
trigger OnAction()
begin
VerifyTotal(Rec);
Post(CODEUNIT::"Purch.-Post + Print");
end;
}
action(PostBatch)
{
ApplicationArea = Basic, Suite;
Caption = 'Post &Batch';
Ellipsis = true;
Image = PostBatch;
ToolTip = 'Post several documents at once. A report request window opens where you can specify which documents to post.';
trigger OnAction()
var
PurchaseHeader: Record "Purchase Header";
SelectionFilterManagement: Codeunit SelectionFilterManagement;
begin
VerifyTotal(Rec);
CurrPage.SetSelectionFilter(PurchaseHeader);
PurchaseHeader.SetFilter("No.", SelectionFilterManagement.GetSelectionFilterForPurchaseHeader(PurchaseHeader));
REPORT.RunModal(REPORT::"Batch Post Purchase Invoices", true, true, PurchaseHeader);
CurrPage.Update(false);
end;
}
action(RemoveFromJobQueue)
{
ApplicationArea = All;
Caption = 'Remove From Job Queue';
Image = RemoveLine;
ToolTip = 'Remove the scheduled processing of this record from the job queue.';
Visible = JobQueueActive;
trigger OnAction()
begin
Rec.CancelBackgroundPosting();
end;
}
}
}
area(Promoted)
{
group(Category_Category7)
{
Caption = 'Release', Comment = 'Generated from the PromotedActionCategories property index 6.';
ShowAs = SplitButton;
actionref(Release_Promoted; Release)
{
}
actionref(Reopen_Promoted; Reopen)
{
}
}
group(Category_Category5)
{
Caption = 'Posting', Comment = 'Generated from the PromotedActionCategories property index 4.';
ShowAs = SplitButton;
actionref(PostSelected_Promoted; PostSelected)
{
}
actionref(PostBatch_Promoted; PostBatch)
{
}
actionref(Preview_Promoted; Preview)
{
}
actionref(PostAndPrint_Promoted; PostAndPrint)
{
}
}
group(Category_Category6)
{
Caption = 'Request Approval', Comment = 'Generated from the PromotedActionCategories property index 5.';
}
group(Category_Category4)
{
Caption = 'Invoice', Comment = 'Generated from the PromotedActionCategories property index 3.';
actionref(Dimensions_Promoted; Dimensions)
{
}
actionref(PurchaseStatistics_Promoted; PurchaseStatistics)
{
}
actionref("Co&mments_Promoted"; "Co&mments")
{
}
actionref(Approvals_Promoted; Approvals)
{
}
separator(Navigate_Separator)
{
}
actionref(Vendor_Promoted; Vendor)
{
}
}
group(Category_Category8)
{
Caption = 'Navigate', Comment = 'Generated from the PromotedActionCategories property index 7.';
}
group(Category_Report)
{
Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.';
}
}
}
trigger OnAfterGetRecord()
begin
StatusStyleTxt := Rec.GetStatusStyleText();
end;
trigger OnAfterGetCurrRecord()
var
FilteredPurchaseHeader: Record "Purchase Header";
begin
SetControlAppearance();
CurrPage.IncomingDocAttachFactBox.PAGE.LoadDataFromRecord(Rec);
CurrPage.SetSelectionFilter(FilteredPurchaseHeader);
CurrPage.PowerBIEmbeddedReportPart.PAGE.SetFilterToMultipleValues(FilteredPurchaseHeader, FilteredPurchaseHeader.FieldNo("No."));
end;
trigger OnInit()
begin
CurrPage.PowerBIEmbeddedReportPart.PAGE.SetPageContext(CurrPage.ObjectId(false));
end;
trigger OnOpenPage()
var
PurchasesPayablesSetup: Record "Purchases & Payables Setup";
begin
Rec.SetSecurityFilterOnRespCenter();
JobQueueActive := PurchasesPayablesSetup.JobQueueActive();
Rec.CopyBuyFromVendorFilter();
end;
var
OpenPostedPurchaseInvQst: Label 'The invoice is posted as number %1 and moved to the Posted Purchase Invoice window.\\Do you want to open the posted invoice?', Comment = '%1 = posted document number';
TotalsMismatchErr: Label 'The invoice cannot be posted because the total is different from the total on the related incoming document.';
ReportPrint: Codeunit "Test Report-Print";
JobQueueActive: Boolean;
OpenApprovalEntriesExist: Boolean;
CanCancelApprovalForRecord: Boolean;
ReadyToPostQst: Label 'The number of invoices that will be posted is %1. \Do you want to continue?', Comment = '%1 - selected count';
CanRequestApprovalForFlow: Boolean;
CanCancelApprovalForFlow: Boolean;
StatusStyleTxt: Text;
local procedure SetControlAppearance()
var
ApprovalsMgmt: Codeunit "Approvals Mgmt.";
WorkflowWebhookManagement: Codeunit "Workflow Webhook Management";
begin
OpenApprovalEntriesExist := ApprovalsMgmt.HasOpenApprovalEntries(Rec.RecordId);
CanCancelApprovalForRecord := ApprovalsMgmt.CanCancelApprovalForRecord(Rec.RecordId);
WorkflowWebhookManagement.GetCanRequestAndCanCancel(Rec.RecordId, CanRequestApprovalForFlow, CanCancelApprovalForFlow);
end;
procedure Post(PostingCodeunitID: Integer)
var
ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade";
LinesInstructionMgt: Codeunit "Lines Instruction Mgt.";
PreAssignedNo: Code[20];
xLastPostingNo: Code[20];
IsHandled: Boolean;
begin
LinesInstructionMgt.PurchaseCheckAllLinesHaveQuantityAssigned(Rec);
PreAssignedNo := Rec."No.";
xLastPostingNo := Rec."Last Posting No.";
Rec.SendToPosting(PostingCodeunitID);
IsHandled := false;
OnPostBeforeNavigateAfterPosting(Rec, PostingCodeunitID, IsHandled);
if IsHandled then
exit;
if ApplicationAreaMgmtFacade.IsFoundationEnabled() then
ShowPostedConfirmationMessage(PreAssignedNo, xLastPostingNo);
end;
local procedure ShowPostedConfirmationMessage(PreAssignedNo: Code[20]; xLastPostingNo: Code[20])
var
PurchInvHeader: Record "Purch. Inv. Header";
InstructionMgt: Codeunit "Instruction Mgt.";
begin
if (Rec."Last Posting No." <> '') and (Rec."Last Posting No." <> xLastPostingNo) then
PurchInvHeader.SetRange("No.", Rec."Last Posting No.")
else
PurchInvHeader.SetRange("Pre-Assigned No.", PreAssignedNo);
if PurchInvHeader.FindFirst() then
if InstructionMgt.ShowConfirm(StrSubstNo(OpenPostedPurchaseInvQst, PurchInvHeader."No."),
InstructionMgt.ShowPostedConfirmationMessageCode())
then
InstructionMgt.ShowPostedDocument(PurchInvHeader, Page::"Purchase Invoices");
end;
procedure VerifyTotal(PurchaseHeader: Record "Purchase Header")
begin
if not PurchaseHeader.IsTotalValid() then
Error(TotalsMismatchErr);
end;
[IntegrationEvent(true, false)]
local procedure OnPostBeforeNavigateAfterPosting(var PurchaseHeader: Record "Purchase Header"; var PostingCodeunitID: Integer; var IsHandled: Boolean)
begin
end;
}