Page 143 Posted Sales Invoices
src/Layers/W1/BaseApp/Sales/History/PostedSalesInvoices.Page.al843 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.Sales.History;using Microsoft.CRM.Outlook;using Microsoft.EServices.EDocument;using Microsoft.Finance.Dimension;using Microsoft.Finance.GeneralLedger.Ledger;using Microsoft.Foundation.Attachment;using Microsoft.Integration.Dataverse;using Microsoft.Sales.Comment;using Microsoft.Sales.Customer;using Microsoft.Sales.Document;using Microsoft.Utilities;/// <summary>/// Lists all posted sales invoices for viewing, printing, and navigation./// </summary>page 143 "Posted Sales Invoices"{ AdditionalSearchTerms = 'posted bill'; ApplicationArea = Basic, Suite; Caption = 'Posted Sales Invoices'; CardPageID = "Posted Sales Invoice"; Editable = false; PageType = List; QueryCategory = 'Posted Sales Invoices'; SourceTable = "Sales Invoice Header"; SourceTableView = sorting("Posting Date") order(descending); UsageCategory = History; AboutTitle = 'About posted sales invoices'; AboutText = 'When sales invoices are posted, they appear here where you can follow the remaining amounts to be paid by your customers.'; layout { area(content) { repeater(Control1) { ShowCaption = false; field("No."; Rec."No.") { ApplicationArea = Basic, Suite; AboutTitle = 'The final invoice number (No.)'; AboutText = 'This is the invoice number uniquely identifying each posted sale. Your customers see this number on the invoices they receive from you.'; } field("Order No."; Rec."Order No.") { ApplicationArea = Suite; Visible = false; } field("Sell-to Customer No."; Rec."Sell-to Customer No.") { ApplicationArea = Basic, Suite; Caption = 'Customer No.'; } field("Sell-to Customer Name"; Rec."Sell-to Customer Name") { ApplicationArea = Basic, Suite; Caption = 'Customer Name'; } field("Currency Code"; Rec."Currency Code") { ApplicationArea = Suite; } field("Due Date"; Rec."Due Date") { ApplicationArea = Basic, Suite; } field(Amount; Rec.Amount) { ApplicationArea = Basic, Suite; trigger OnDrillDown() begin DoDrillDown(); end; } field("Amount Including VAT"; Rec."Amount Including VAT") { ApplicationArea = Basic, Suite; trigger OnDrillDown() begin DoDrillDown(); end; } field("Remaining Amount"; Rec."Remaining Amount") { ApplicationArea = Basic, Suite; AboutTitle = 'What remains to be paid'; AboutText = 'This column shows you what is not yet paid on each invoice. When full payment is registered, an invoice is marked as *Closed*.'; ToolTip = 'Specifies the amount that remains to be paid for the posted sales invoice.'; } field("Sell-to Post Code"; Rec."Sell-to Post Code") { ApplicationArea = Basic, Suite; Visible = false; } field("Sell-to Country/Region Code"; Rec."Sell-to Country/Region Code") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the country/region code of the customer''s main address.'; Visible = false; } field("Sell-to Contact"; Rec."Sell-to Contact") { ApplicationArea = Basic, Suite; Visible = false; } field("Bill-to Customer No."; Rec."Bill-to Customer No.") { ApplicationArea = Basic, Suite; Visible = false; } field("Bill-to Name"; Rec."Bill-to Name") { ApplicationArea = Basic, Suite; Visible = false; } field("Bill-to Post Code"; Rec."Bill-to Post Code") { ApplicationArea = Basic, Suite; Visible = false; } field("Bill-to Country/Region Code"; Rec."Bill-to Country/Region Code") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the country/region code of the customer''s billing address.'; Visible = false; } field("Bill-to Contact"; Rec."Bill-to Contact") { ApplicationArea = Basic, Suite; Visible = false; } field("Ship-to Code"; Rec."Ship-to Code") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies a code for an alternate shipment address if you want to ship to another address than the one that has been entered automatically. This field is also used in case of drop shipment.'; 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; ToolTip = 'Specifies the country/region code of the address that the items are shipped to.'; Visible = false; } field("Ship-to Contact"; Rec."Ship-to Contact") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the name of the contact person at the address that the items are shipped to.'; Visible = false; } field("Posting Date"; Rec."Posting Date") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the date when the invoice was posted.'; Visible = false; } field("Salesperson Code"; Rec."Salesperson Code") { ApplicationArea = 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("No. Printed"; Rec."No. Printed") { ApplicationArea = Basic, Suite; } field("Document Date"; Rec."Document Date") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies the date when the related document was created.'; Visible = false; } field("External Document No."; Rec."External Document No.") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies a document number that refers to the customer''s or vendor''s numbering system.'; Visible = false; } field("Payment Terms Code"; Rec."Payment Terms Code") { ApplicationArea = Basic, Suite; ToolTip = 'Specifies a formula that calculates the payment due date, payment discount date, and payment discount amount.'; Visible = false; } field("Payment Discount %"; Rec."Payment Discount %") { ApplicationArea = Basic, Suite; Visible = false; } field("Shipment Method Code"; Rec."Shipment Method Code") { ApplicationArea = Suite; ToolTip = 'Specifies the delivery conditions of the related shipment, such as free on board (FOB).'; Visible = false; } field("Shipping Agent Code"; Rec."Shipping Agent Code") { ApplicationArea = Suite; ToolTip = 'Specifies the code for the shipping agent who is transporting the items.'; Visible = false; } field(Closed; Rec.Closed) { ApplicationArea = Basic, Suite; ToolTip = 'Specifies if the posted sales invoice is paid. The check box will also be selected if a credit memo for the remaining amount has been applied.'; } field(Cancelled; Rec.Cancelled) { ApplicationArea = Basic, Suite; HideValue = not Rec.Cancelled; Style = Unfavorable; StyleExpr = Rec.Cancelled; trigger OnDrillDown() begin Rec.ShowCorrectiveCreditMemo(); end; } field(Corrective; Rec.Corrective) { ApplicationArea = Basic, Suite; HideValue = not Rec.Corrective; Style = Unfavorable; StyleExpr = Rec.Corrective; trigger OnDrillDown() begin Rec.ShowCancelledCreditMemo(); end; } field("Shipment Date"; Rec."Shipment Date") { ApplicationArea = Basic, Suite; Visible = false; } field("Document Exchange Status"; Rec."Document Exchange Status") { ApplicationArea = Basic, Suite; StyleExpr = DocExchStatusStyle; Visible = DocExchStatusVisible; trigger OnDrillDown() var DocExchServDocStatus: Codeunit "Doc. Exch. Serv.- Doc. Status"; begin DocExchServDocStatus.DocExchStatusDrillDown(Rec); end; } field("Coupled to Dataverse"; Rec."Coupled to Dataverse") { ApplicationArea = All; Visible = CRMIntegrationEnabled; } } } area(factboxes) { part("Attached Documents List"; "Doc. Attachment List Factbox") { ApplicationArea = All; Caption = 'Documents'; UpdatePropagation = Both; SubPageLink = "Table ID" = const(Database::"Sales Invoice Header"), "No." = field("No."); } part(IncomingDocAttachFactBox; "Incoming Doc. Attach. FactBox") { ApplicationArea = Basic, Suite; ShowFilter = false; Visible = not IsOfficeAddin; } part(GLEntriesPart; "G/L Entries Part") { ApplicationArea = Basic, Suite; Caption = 'Related G/L Entries'; ShowFilter = false; SubPageLink = "Posting Date" = field("Posting Date"), "Document No." = field("No."); } systempart(Control1900383207; Links) { ApplicationArea = RecordLinks; Visible = false; } systempart(Control1905767507; Notes) { ApplicationArea = Notes; } } } actions { area(navigation) { group("&Invoice") { Caption = '&Invoice'; Image = Invoice; action(Statistics) { ApplicationArea = Suite; Caption = 'Statistics'; Image = Statistics; RunObject = Page "Sales Invoice Statistics"; RunPageLink = "No." = field("No."); ShortCutKey = 'F7'; AboutTitle = 'Your profit from a sale'; AboutText = 'Go here to see statistics about the selected invoice, your profit, and associated taxes.'; ToolTip = 'View statistical information, such as the value of posted entries, for the record.'; } action("Co&mments") { ApplicationArea = Comments; Caption = 'Co&mments'; Image = ViewComments; RunObject = Page "Sales Comment Sheet"; RunPageLink = "Document Type" = const("Posted Invoice"), "No." = field("No."); 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.ShowDimensions(); end; } action(IncomingDoc) { AccessByPermission = TableData "Incoming Document" = R; ApplicationArea = Basic, Suite; Caption = 'Incoming Document'; Image = Document; ToolTip = 'View or create an incoming document record that is linked to the entry or document.'; trigger OnAction() var IncomingDocument: Record "Incoming Document"; begin IncomingDocument.ShowCard(Rec."No.", Rec."Posting Date"); end; } } group(ActionGroupCRM) { Caption = 'Dynamics 365 Sales'; Visible = CRMIntegrationEnabled; action(CRMGotoInvoice) { ApplicationArea = Suite; Caption = 'Invoice'; Enabled = CRMIsCoupledToRecord; Image = CoupledSalesInvoice; ToolTip = 'Open the coupled Dynamics 365 Sales invoice.'; trigger OnAction() var CRMIntegrationManagement: Codeunit "CRM Integration Management"; begin CRMIntegrationManagement.ShowCRMEntityFromRecordID(Rec.RecordId); end; } action(CreateInCRM) { ApplicationArea = Suite; Caption = 'Create Invoice in Dynamics 365 Sales'; Enabled = not CRMIsCoupledToRecord; Image = NewSalesInvoice; ToolTip = 'Generate the document in the coupled Dynamics 365 Sales account.'; trigger OnAction() var SalesInvoiceHeader: Record "Sales Invoice Header"; CRMIntegrationManagement: Codeunit "CRM Integration Management"; begin CurrPage.SetSelectionFilter(SalesInvoiceHeader); CRMIntegrationManagement.CreateNewRecordsInCRM(SalesInvoiceHeader); end; } action(ShowLog) { ApplicationArea = Suite; Caption = 'Synchronization Log'; Image = Log; ToolTip = 'View integration synchronization jobs for the posted sales invoice table.'; trigger OnAction() var CRMIntegrationManagement: Codeunit "CRM Integration Management"; begin CRMIntegrationManagement.ShowLog(Rec.RecordId); end; } } } area(processing) { action(SendCustom) { ApplicationArea = Basic, Suite; Caption = 'Send'; Ellipsis = true; Enabled = HasPostedSalesInvoices; Image = SendToMultiple; ToolTip = 'Prepare to send the document according to the customer''s sending profile, such as attached to an email. The Send document to window opens where you can confirm or select a sending profile.'; trigger OnAction() var SalesInvHeader: Record "Sales Invoice Header"; begin SalesInvHeader := Rec; CurrPage.SetSelectionFilter(SalesInvHeader); SalesInvHeader.SendRecords(); end; } action(Print) { ApplicationArea = Basic, Suite; Caption = '&Print'; Ellipsis = true; Image = Print; ToolTip = 'Prepare to print the document. A report request window for the document opens where you can specify what to include on the print-out.'; Visible = not IsOfficeAddin; trigger OnAction() var SalesInvHeader: Record "Sales Invoice Header"; IsHandled: Boolean; begin SalesInvHeader := Rec; CurrPage.SetSelectionFilter(SalesInvHeader); IsHandled := false; OnPrintActionOnBeforePrintRecords(SalesInvHeader, IsHandled); if not IsHandled then SalesInvHeader.PrintRecords(true); end; } action(Email) { ApplicationArea = Basic, Suite; Caption = 'Send by &Email'; Image = Email; ToolTip = 'Prepare to send the document by email. The Send Email window opens prefilled for the customer where you can add or change information before you send the email.'; trigger OnAction() var SalesInvHeader: Record "Sales Invoice Header"; begin SalesInvHeader := Rec; CurrPage.SetSelectionFilter(SalesInvHeader); SalesInvHeader.EmailRecords(true); end; } action(AttachAsPDF) { ApplicationArea = Basic, Suite; Caption = 'Attach as PDF'; Image = PrintAttachment; ToolTip = 'Create a PDF file and attach it to the document.'; trigger OnAction() var SalesInvHeader: Record "Sales Invoice Header"; begin SalesInvHeader := Rec; CurrPage.SetSelectionFilter(SalesInvHeader); Rec.PrintToDocumentAttachment(SalesInvHeader); end; } action(Navigate) { ApplicationArea = Basic, Suite; Caption = 'Find entries...'; Image = Navigate; ShortCutKey = 'Ctrl+Alt+Q'; ToolTip = 'Find entries and documents that exist for the document number and posting date on the selected document. (Formerly this action was named Navigate.)'; Visible = not IsOfficeAddin; trigger OnAction() begin Rec.Navigate(); end; } action(ActivityLog) { ApplicationArea = Basic, Suite; Caption = 'Activity Log'; Image = Log; ToolTip = 'View the status and any errors if the document was sent as an electronic document or OCR file through the document exchange service.'; trigger OnAction() var ActivityLog: Record "Activity Log"; begin ActivityLog.ShowEntries(Rec.RecordId); end; } group(Correct) { Caption = 'Correct'; action(CorrectInvoice) { ApplicationArea = Basic, Suite; Caption = 'Correct'; Enabled = HasPostedSalesInvoices; Image = Undo; Scope = Repeater; ToolTip = 'Reverse this posted invoice. A credit memo will be created and matched with the invoice, and the invoice will be canceled. Shipments for the invoice will be reversed. To create a new invoice with the same information, use the Copy function. When you copy an invoice, remember to post shipments for the new invoice.'; Visible = not Rec.Cancelled; trigger OnAction() begin CODEUNIT.Run(CODEUNIT::"Correct PstdSalesInv (Yes/No)", Rec); end; } action(CancelInvoice) { ApplicationArea = Basic, Suite; Caption = 'Cancel'; Enabled = HasPostedSalesInvoices; Image = Cancel; Scope = Repeater; ToolTip = 'Create and post a sales credit memo that reverses this posted sales invoice. This posted sales invoice will be canceled.'; Visible = not Rec.Cancelled; trigger OnAction() begin CODEUNIT.Run(CODEUNIT::"Cancel PstdSalesInv (Yes/No)", Rec); end; } action(CreateCreditMemo) { ApplicationArea = Basic, Suite; Caption = 'Create Corrective Credit Memo'; Enabled = HasPostedSalesInvoices; Image = CreateCreditMemo; Scope = Repeater; ToolTip = 'Create a credit memo for this posted invoice that you complete and post manually to reverse the posted invoice.'; trigger OnAction() var SalesHeader: Record "Sales Header"; CorrectPostedSalesInvoice: Codeunit "Correct Posted Sales Invoice"; IsHandled: Boolean; begin IsHandled := false; OnBeforeCreateCreditMemoOnAction(Rec, IsHandled); if IsHandled then exit; if CorrectPostedSalesInvoice.CreateCreditMemoCopyDocument(Rec, SalesHeader) then PAGE.Run(PAGE::"Sales Credit Memo", SalesHeader); end; } action(ShowCreditMemo) { ApplicationArea = Basic, Suite; Caption = 'Show Canceled/Corrective Credit Memo'; Image = CreditMemo; Scope = Repeater; ToolTip = 'Open the posted sales credit memo that was created when you canceled the posted sales invoice. If the posted sales invoice is the result of a canceled sales credit memo, then the canceled sales credit memo will open.'; Visible = Rec.Cancelled or Rec.Corrective; trigger OnAction() begin Rec.ShowCanceledOrCorrCrMemo(); end; } } group(Invoice) { Caption = 'Invoice'; Image = Invoice; action(Customer) { ApplicationArea = Basic, Suite; Caption = 'Customer'; Image = Customer; RunObject = Page "Customer Card"; RunPageLink = "No." = field("Sell-to Customer No."); Scope = Repeater; ShortCutKey = 'Shift+F7'; ToolTip = 'View or edit detailed information about the customer.'; } } action("Update Document") { ApplicationArea = Basic, Suite; Caption = 'Update Document'; Image = Edit; ToolTip = 'Add new information that is relevant to the document, such as a payment reference. You can only edit a few fields because the document has already been posted.'; trigger OnAction() var PostedSalesInvUpdate: Page "Posted Sales Inv. - Update"; begin PostedSalesInvUpdate.LookupMode := true; PostedSalesInvUpdate.SetRec(Rec); PostedSalesInvUpdate.RunModal(); end; } } area(Promoted) { group(Category_Process) { Caption = 'Process', Comment = 'Generated from the PromotedActionCategories property index 1.'; actionref("Update Document_Promoted"; "Update Document") { } actionref(Navigate_Promoted; Navigate) { } } group(Category_Category7) { Caption = 'Print/Send', Comment = 'Generated from the PromotedActionCategories property index 6.'; actionref(Print_Promoted; Print) { } actionref(Email_Promoted; Email) { } actionref(SendCustom_Promoted; SendCustom) { } actionref(AttachAsPDF_Promoted; AttachAsPDF) { } } group(Category_Category4) { Caption = 'Invoice', Comment = 'Generated from the PromotedActionCategories property index 3.'; actionref(Dimensions_Promoted; Dimensions) { } actionref(Statistics_Promoted; Statistics) { } actionref("Co&mments_Promoted"; "Co&mments") { } actionref(ActivityLog_Promoted; ActivityLog) { } separator(Navigate_Separator) { } actionref(IncomingDoc_Promoted; IncomingDoc) { } actionref(Customer_Promoted; Customer) { } } group(Category_Category6) { Caption = 'Correct', Comment = 'Generated from the PromotedActionCategories property index 5.'; ShowAs = SplitButton; actionref(CorrectInvoice_Promoted; CorrectInvoice) { } actionref(CancelInvoice_Promoted; CancelInvoice) { } actionref(CreateCreditMemo_Promoted; CreateCreditMemo) { } actionref(ShowCreditMemo_Promoted; ShowCreditMemo) { } } group(Category_Category5) { Caption = 'Navigate', Comment = 'Generated from the PromotedActionCategories property index 4.'; } group(Category_Report) { Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.'; } group(Category_Synchronize) { Caption = 'Synchronize'; Visible = CRMIntegrationEnabled; actionref(CreateInCRM_Promoted; CreateInCRM) { } actionref(CRMGotoInvoice_Promoted; CRMGotoInvoice) { } actionref(ShowLog_Promoted; ShowLog) { } } } } views { view(OnlyUnpaid) { Caption = 'Unpaid'; Filters = where(Cancelled = const(false), Closed = const(false)); } view(OnlyPaid) { Caption = 'Paid'; Filters = where(Cancelled = const(false), Closed = const(true)); } view(OnlyCancelled) { Caption = 'Canceled'; Filters = where(Cancelled = const(true)); } } trigger OnAfterGetCurrRecord() var CRMCouplingManagement: Codeunit "CRM Coupling Management"; IsHandled: Boolean; begin IsHandled := false; OnBeforeOnAfterGetCurrRecord(Rec, IsHandled, HasPostedSalesInvoices, CRMIsCoupledToRecord, CRMIntegrationEnabled); if IsHandled then exit; HasPostedSalesInvoices := true; if not GuiAllowed() then exit; CurrPage.IncomingDocAttachFactBox.PAGE.LoadDataFromRecord(Rec); CRMIsCoupledToRecord := CRMIntegrationEnabled; if CRMIsCoupledToRecord then CRMIsCoupledToRecord := CRMCouplingManagement.IsRecordCoupledToCRM(Rec.RecordId); end; trigger OnAfterGetRecord() begin if DocExchStatusVisible then DocExchStatusStyle := Rec.GetDocExchStatusStyle(); end; trigger OnOpenPage() var SalesInvoiceHeader: Record "Sales Invoice Header"; CRMIntegrationManagement: Codeunit "CRM Integration Management"; OfficeMgt: Codeunit "Office Management"; HasFilters: Boolean; begin HasFilters := Rec.GetFilters() <> ''; Rec.SetSecurityFilterOnRespCenter(); OnOpenPageOnAfterSetFilters(Rec); CRMIntegrationEnabled := CRMIntegrationManagement.IsCRMIntegrationEnabled(); if HasFilters and not Rec.Find() then if Rec.FindFirst() then; IsOfficeAddin := OfficeMgt.IsAvailable(); SalesInvoiceHeader.CopyFilters(Rec); SalesInvoiceHeader.SetFilter("Document Exchange Status", '<>%1', Rec."Document Exchange Status"::"Not Sent"); DocExchStatusVisible := not SalesInvoiceHeader.IsEmpty(); end; local procedure DoDrillDown() var SalesInvoiceHeader: Record "Sales Invoice Header"; PageManagement: Codeunit "Page Management"; begin SalesInvoiceHeader.Copy(Rec); SalesInvoiceHeader.SetRange("No."); PageManagement.PageRun(SalesInvoiceHeader); end; var DocExchStatusStyle: Text; CRMIntegrationEnabled: Boolean; CRMIsCoupledToRecord: Boolean; DocExchStatusVisible: Boolean; IsOfficeAddin: Boolean; HasPostedSalesInvoices: Boolean; [IntegrationEvent(true, false)] local procedure OnOpenPageOnAfterSetFilters(var SalesInvoiceHeader: Record "Sales Invoice Header") begin end; [IntegrationEvent(false, false)] local procedure OnBeforeCreateCreditMemoOnAction(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeOnAfterGetCurrRecord(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean; var HasPostedSalesInvoices: Boolean; var CRMIsCoupledToRecord: Boolean; var CRMIntegrationEnabled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnPrintActionOnBeforePrintRecords(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean) begin end;}