Page 140 Posted Purchase Credit Memo, source in 29
Source29
src/Layers/W1/BaseApp/Purchases/History/PostedPurchaseCreditMemo.Page.al872 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.History;
using Microsoft.CRM.Contact;
using Microsoft.CRM.Outlook;
using Microsoft.EServices.EDocument;
using Microsoft.Finance.Currency;
using Microsoft.Finance.Dimension;
using Microsoft.Finance.VAT.Calculation;
using Microsoft.Foundation.Address;
using Microsoft.Foundation.Attachment;
using Microsoft.Purchases.Comment;
using Microsoft.Purchases.Vendor;
using System.Automation;
page 140 "Posted Purchase Credit Memo"
{
Caption = 'Posted Purchase Credit Memo';
InsertAllowed = false;
PageType = Document;
RefreshOnActivate = true;
SourceTable = "Purch. Cr. Memo Hdr.";
layout
{
area(content)
{
group(General)
{
Caption = 'General';
field("No."; Rec."No.")
{
ApplicationArea = All;
Editable = false;
Importance = Promoted;
}
field("Buy-from Vendor No."; Rec."Buy-from Vendor No.")
{
ApplicationArea = Basic, Suite;
Caption = 'Vendor No.';
Editable = false;
Visible = false;
}
field("Buy-from Vendor Name"; Rec."Buy-from Vendor Name")
{
ApplicationArea = All;
Caption = 'Vendor';
Editable = false;
Importance = Promoted;
TableRelation = Vendor.Name;
}
field("Buy-from Vendor Name 2"; Rec."Buy-from Vendor Name 2")
{
ApplicationArea = Basic, Suite;
Caption = 'Vendor Name 2';
Editable = false;
Importance = Additional;
Visible = false;
}
group("Buy-from")
{
Caption = 'Buy-from';
field("Buy-from Address"; Rec."Buy-from Address")
{
ApplicationArea = Basic, Suite;
Caption = 'Address';
Editable = false;
Importance = Additional;
}
field("Buy-from Address 2"; Rec."Buy-from Address 2")
{
ApplicationArea = Basic, Suite;
Caption = 'Address 2';
Editable = false;
Importance = Additional;
}
field("Buy-from City"; Rec."Buy-from City")
{
ApplicationArea = Basic, Suite;
Caption = 'City';
Editable = false;
Importance = Additional;
}
group(Control37)
{
ShowCaption = false;
Visible = IsBuyFromCountyVisible;
field("Buy-from County"; Rec."Buy-from County")
{
ApplicationArea = Basic, Suite;
CaptionClass = '5,1,' + Rec."Buy-from Country/Region Code";
Editable = false;
Importance = Additional;
}
}
field("Buy-from Post Code"; Rec."Buy-from Post Code")
{
ApplicationArea = Basic, Suite;
Caption = 'Post Code';
Editable = false;
Importance = Additional;
ToolTip = 'Specifies the postal code.';
}
field("Buy-from Country/Region Code"; Rec."Buy-from Country/Region Code")
{
ApplicationArea = Basic, Suite;
Caption = 'Country/Region';
Editable = false;
Importance = Additional;
}
field("Buy-from Contact No."; Rec."Buy-from Contact No.")
{
ApplicationArea = Basic, Suite;
Caption = 'Contact No.';
Editable = false;
Importance = Additional;
}
field(BuyFromContactPhoneNo; BuyFromContact."Phone No.")
{
ApplicationArea = Suite;
Caption = 'Phone No.';
Importance = Additional;
Editable = false;
ExtendedDatatype = PhoneNo;
ToolTip = 'Specifies the telephone number of the vendor contact person.';
}
field(BuyFromContactMobilePhoneNo; BuyFromContact."Mobile Phone No.")
{
ApplicationArea = Suite;
Caption = 'Mobile Phone No.';
Importance = Additional;
Editable = false;
ExtendedDatatype = PhoneNo;
ToolTip = 'Specifies the mobile telephone number of the vendor contact person.';
}
field(BuyFromContactEmail; BuyFromContact."E-Mail")
{
ApplicationArea = Suite;
Caption = 'Email';
Importance = Additional;
Editable = false;
ExtendedDatatype = EMail;
ToolTip = 'Specifies the email address of the vendor contact person.';
}
}
field("Buy-from Contact"; Rec."Buy-from Contact")
{
ApplicationArea = Basic, Suite;
Caption = 'Contact';
Editable = false;
ToolTip = 'Specifies the name of the person to contact at the vendor who shipped the items.';
}
field("Posting Date"; Rec."Posting Date")
{
ApplicationArea = Basic, Suite;
Editable = false;
Importance = Promoted;
}
field("VAT Reporting Date"; Rec."VAT Reporting Date")
{
ApplicationArea = VAT;
Importance = Promoted;
Editable = false;
Visible = VATDateEnabled;
}
field("Document Date"; Rec."Document Date")
{
ApplicationArea = Basic, Suite;
Editable = false;
}
field("Pre-Assigned No."; Rec."Pre-Assigned No.")
{
ApplicationArea = Basic, Suite;
Editable = false;
Importance = Additional;
}
field("Vendor Cr. Memo No."; Rec."Vendor Cr. Memo No.")
{
ApplicationArea = Basic, Suite;
Editable = false;
Importance = Promoted;
}
field("Spend Request No."; Rec."Spend Request No.")
{
ApplicationArea = Basic, Suite;
Editable = false;
Importance = Additional;
ToolTip = 'Specifies the spend request that this purchase document relates to.';
}
field("Order Address Code"; Rec."Order Address Code")
{
ApplicationArea = Basic, Suite;
Editable = false;
}
field("Purchaser Code"; Rec."Purchaser Code")
{
ApplicationArea = Suite;
Editable = false;
Importance = Additional;
}
field("Responsibility Center"; Rec."Responsibility Center")
{
ApplicationArea = Suite;
Editable = false;
Importance = Additional;
}
field(Cancelled; Rec.Cancelled)
{
ApplicationArea = Basic, Suite;
Importance = Additional;
Style = Unfavorable;
StyleExpr = Rec.Cancelled;
trigger OnDrillDown()
begin
Rec.ShowCorrectiveInvoice();
end;
}
field(Corrective; Rec.Corrective)
{
ApplicationArea = Basic, Suite;
Importance = Additional;
Style = Unfavorable;
StyleExpr = Rec.Corrective;
trigger OnDrillDown()
begin
Rec.ShowCancelledInvoice();
end;
}
field("No. Printed"; Rec."No. Printed")
{
ApplicationArea = Basic, Suite;
Editable = false;
Importance = Additional;
}
}
part(PurchCrMemoLines; "Posted Purch. Cr. Memo Subform")
{
ApplicationArea = Basic, Suite;
SubPageLink = "Document No." = field("No.");
}
group("Invoice Details")
{
Caption = 'Credit Memo Details';
field("Currency Code"; Rec."Currency Code")
{
ApplicationArea = Suite;
Importance = Promoted;
trigger OnAssistEdit()
var
UpdateCurrencyFactor: Codeunit "Update Currency Factor";
begin
ChangeExchangeRate.SetParameter(Rec."Currency Code", Rec."Currency Factor", Rec."Posting Date");
ChangeExchangeRate.Editable(false);
if ChangeExchangeRate.RunModal() = ACTION::OK then begin
Rec."Currency Factor" := ChangeExchangeRate.GetParameter();
UpdateCurrencyFactor.ModifyPostedPurchaseCreditMemo(Rec);
end;
Clear(ChangeExchangeRate);
end;
}
field("Shortcut Dimension 1 Code"; Rec."Shortcut Dimension 1 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Importance = Additional;
}
field("Shortcut Dimension 2 Code"; Rec."Shortcut Dimension 2 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Importance = Additional;
}
field("Location Code"; Rec."Location Code")
{
ApplicationArea = Location;
Editable = false;
}
field("Vendor Posting Group"; Rec."Vendor Posting Group")
{
ApplicationArea = Basic, Suite;
Editable = false;
Visible = false;
}
field("Applies-to Doc. Type"; Rec."Applies-to Doc. Type")
{
ApplicationArea = Basic, Suite;
Editable = false;
}
field("Applies-to Doc. No."; Rec."Applies-to Doc. No.")
{
ApplicationArea = Basic, Suite;
Editable = false;
}
field(Correction; Rec.Correction)
{
ApplicationArea = Basic, Suite;
Editable = false;
}
}
group("Shipping and Payment")
{
Caption = 'Shipping and Payment';
group("Ship-to")
{
Caption = 'Ship-to';
field("Ship-to Name"; Rec."Ship-to Name")
{
ApplicationArea = Basic, Suite;
Caption = 'Name';
Editable = false;
ToolTip = 'Specifies the name of the company at the address to which the items in the purchase order were shipped.';
}
field("Ship-to Address"; Rec."Ship-to Address")
{
ApplicationArea = Basic, Suite;
Caption = 'Address';
Editable = false;
}
field("Ship-to Address 2"; Rec."Ship-to Address 2")
{
ApplicationArea = Basic, Suite;
Caption = 'Address 2';
Editable = false;
}
field("Ship-to City"; Rec."Ship-to City")
{
ApplicationArea = Basic, Suite;
Caption = 'City';
Editable = false;
}
group(Control43)
{
ShowCaption = false;
Visible = IsShipToCountyVisible;
field("Ship-to County"; Rec."Ship-to County")
{
ApplicationArea = Basic, Suite;
CaptionClass = '5,1,' + Rec."Ship-to Country/Region Code";
Editable = false;
}
}
field("Ship-to Post Code"; Rec."Ship-to Post Code")
{
ApplicationArea = Basic, Suite;
Caption = 'Post Code';
Editable = false;
ToolTip = 'Specifies the postal code.';
}
field("Ship-to Country/Region Code"; Rec."Ship-to Country/Region Code")
{
ApplicationArea = Basic, Suite;
Caption = 'Country/Region';
Editable = false;
}
field("Ship-to Phone No."; Rec."Ship-to Phone No.")
{
ApplicationArea = Basic, Suite;
Caption = 'Phone No.';
Editable = false;
}
field("Ship-to Contact"; Rec."Ship-to Contact")
{
ApplicationArea = Basic, Suite;
Caption = 'Contact';
Editable = false;
}
}
group("Pay-to")
{
Caption = 'Pay-to';
field("Pay-to Name"; Rec."Pay-to Name")
{
ApplicationArea = Basic, Suite;
Caption = 'Name';
Editable = false;
Importance = Promoted;
}
field("Pay-to Name 2"; Rec."Pay-to Name 2")
{
ApplicationArea = Basic, Suite;
Caption = 'Name 2';
Editable = false;
Importance = Additional;
Visible = false;
}
field("Pay-to Address"; Rec."Pay-to Address")
{
ApplicationArea = Basic, Suite;
Caption = 'Address';
Editable = false;
Importance = Additional;
}
field("Pay-to Address 2"; Rec."Pay-to Address 2")
{
ApplicationArea = Basic, Suite;
Caption = 'Address 2';
Editable = false;
Importance = Additional;
}
field("Pay-to City"; Rec."Pay-to City")
{
ApplicationArea = Basic, Suite;
Caption = 'City';
Editable = false;
Importance = Additional;
}
group(Control46)
{
ShowCaption = false;
Visible = IsPayToCountyVisible;
field("Pay-to County"; Rec."Pay-to County")
{
ApplicationArea = Basic, Suite;
CaptionClass = '5,1,' + Rec."Pay-to Country/Region Code";
Editable = false;
Importance = Additional;
}
}
field("Pay-to Post Code"; Rec."Pay-to Post Code")
{
ApplicationArea = Basic, Suite;
Caption = 'Post Code';
Editable = false;
Importance = Additional;
ToolTip = 'Specifies the postal code.';
}
field("Pay-to Country/Region Code"; Rec."Pay-to Country/Region Code")
{
ApplicationArea = Basic, Suite;
Caption = 'Country/Region';
Editable = false;
Importance = Additional;
}
field("Pay-to Contact No."; Rec."Pay-to Contact No.")
{
ApplicationArea = Basic, Suite;
Caption = 'Contact No.';
Editable = false;
Importance = Additional;
}
field(PayToContactPhoneNo; PayToContact."Phone No.")
{
ApplicationArea = Basic, Suite;
Caption = 'Phone No.';
Editable = false;
Importance = Additional;
ExtendedDatatype = PhoneNo;
ToolTip = 'Specifies the telephone number of the vendor contact person.';
}
field(PayToContactMobilePhoneNo; PayToContact."Mobile Phone No.")
{
ApplicationArea = Basic, Suite;
Caption = 'Mobile Phone No.';
Editable = false;
Importance = Additional;
ExtendedDatatype = PhoneNo;
ToolTip = 'Specifies the mobile telephone number of the vendor contact person.';
}
field(PayToContactEmail; PayToContact."E-Mail")
{
ApplicationArea = Basic, Suite;
Caption = 'Email';
Editable = false;
Importance = Additional;
ExtendedDatatype = Email;
ToolTip = 'Specifies the email address of the vendor contact person..';
}
field("Pay-to Contact"; Rec."Pay-to Contact")
{
ApplicationArea = Basic, Suite;
Caption = 'Contact';
Editable = false;
}
}
}
}
area(factboxes)
{
part("Attached Documents List"; "Doc. Attachment List Factbox")
{
ApplicationArea = All;
Caption = 'Documents';
UpdatePropagation = Both;
SubPageLink = "Table ID" = const(Database::"Purch. Cr. Memo Hdr."),
"No." = field("No.");
}
part(IncomingDocAttachFactBox; "Incoming Doc. Attach. FactBox")
{
ApplicationArea = Basic, Suite;
ShowFilter = false;
Visible = not IsOfficeAddin;
}
systempart(Control1900383207; Links)
{
ApplicationArea = RecordLinks;
Visible = false;
}
systempart(Control1905767507; Notes)
{
ApplicationArea = Notes;
}
}
}
actions
{
area(navigation)
{
group("&Cr. Memo")
{
Caption = '&Cr. Memo';
Image = CreditMemo;
action(Statistics)
{
ApplicationArea = Basic, Suite;
Caption = 'Statistics';
Image = Statistics;
RunObject = Page "Purch. Credit Memo Statistics";
RunPageLink = "No." = field("No.");
ShortCutKey = 'F7';
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 "Purch. Comment Sheet";
RunPageLink = "Document Type" = const("Posted Credit Memo"),
"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.ShowDimensions();
end;
}
action(Approvals)
{
AccessByPermission = TableData "Posted 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.ShowPostedApprovalEntries(Rec.RecordId);
end;
}
action(DocAttach)
{
ApplicationArea = All;
Caption = 'Attachments';
Image = Attach;
ToolTip = 'Add a file as an attachment. You can attach images as well as documents.';
trigger OnAction()
var
DocumentAttachmentDetails: Page "Document Attachment Details";
RecRef: RecordRef;
begin
RecRef.GetTable(Rec);
DocumentAttachmentDetails.OpenForRecRef(RecRef);
DocumentAttachmentDetails.RunModal();
end;
}
}
}
area(processing)
{
action(Vendor)
{
ApplicationArea = Basic, Suite;
Caption = 'Vendor';
Image = Vendor;
RunObject = Page "Vendor Card";
RunPageLink = "No." = field("Buy-from Vendor No.");
ShortCutKey = 'Shift+F7';
ToolTip = 'View or edit detailed information about the vendor on the purchase document.';
}
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()
begin
PurchCrMemoHeader := Rec;
CurrPage.SetSelectionFilter(PurchCrMemoHeader);
PurchCrMemoHeader.PrintRecords(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()
begin
PurchCrMemoHeader := Rec;
CurrPage.SetSelectionFilter(PurchCrMemoHeader);
Rec.PrintToDocumentAttachment(PurchCrMemoHeader);
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("Update Document")
{
ApplicationArea = Suite;
Caption = 'Update Document';
Image = Edit;
ToolTip = 'Add new information that is relevant to the document. You can only edit a few fields because the document has already been posted.';
trigger OnAction()
var
PstdPurchCrMemoUpdate: Page "Pstd. Purch. Cr.Memo - Update";
begin
PstdPurchCrMemoUpdate.LookupMode := true;
PstdPurchCrMemoUpdate.SetRec(Rec);
PstdPurchCrMemoUpdate.RunModal();
end;
}
group(Cancel)
{
Caption = 'Cancel';
action(CancelCrMemo)
{
ApplicationArea = Basic, Suite;
Caption = 'Cancel';
Image = Cancel;
ToolTip = 'Create and post a purchase invoice that reverses this posted purchase credit memo. This posted purchase credit memo will be canceled.';
Visible = not Rec.Cancelled and Rec.Corrective;
trigger OnAction()
begin
CODEUNIT.Run(CODEUNIT::"Cancel PstdPurchCrM (Yes/No)", Rec);
end;
}
action(ShowInvoice)
{
ApplicationArea = Basic, Suite;
Caption = 'Show Canceled/Corrective Invoice';
Image = Invoice;
Scope = Repeater;
ToolTip = 'Open the posted purchase invoice that was created when you canceled the posted purchase credit memo. If the posted purchase credit memo is the result of a canceled purchase invoice, then canceled invoice will open.';
Visible = Rec.Cancelled or Rec.Corrective;
trigger OnAction()
begin
Rec.ShowCanceledOrCorrInvoice();
end;
}
}
group(IncomingDocument)
{
Caption = 'Incoming Document';
Image = Documents;
action(IncomingDocCard)
{
ApplicationArea = Basic, Suite;
Caption = 'View Incoming Document';
Enabled = HasIncomingDocument;
Image = ViewOrder;
ToolTip = 'View any incoming document records and file attachments that exist for the entry or document.';
Visible = not IsOfficeAddin;
trigger OnAction()
var
IncomingDocument: Record "Incoming Document";
begin
IncomingDocument.ShowCard(Rec."No.", Rec."Posting Date");
end;
}
action(SelectIncomingDoc)
{
AccessByPermission = TableData "Incoming Document" = R;
ApplicationArea = Basic, Suite;
Caption = 'Select Incoming Document';
Enabled = not HasIncomingDocument;
Image = SelectLineToApply;
ToolTip = 'Select an incoming document record and file attachment that you want to link to the entry or document.';
trigger OnAction()
var
IncomingDocument: Record "Incoming Document";
begin
IncomingDocument.SelectIncomingDocumentForPostedDocument(Rec."No.", Rec."Posting Date", Rec.RecordId);
end;
}
action(IncomingDocAttachFile)
{
ApplicationArea = Basic, Suite;
Caption = 'Create Incoming Document from File';
Ellipsis = true;
Enabled = not HasIncomingDocument;
Image = Attach;
ToolTip = 'Create an incoming document record by selecting a file to attach, and then link the incoming document record to the entry or document.';
trigger OnAction()
var
IncomingDocumentAttachment: Record "Incoming Document Attachment";
begin
IncomingDocumentAttachment.NewAttachmentFromPostedDocument(Rec."No.", Rec."Posting Date");
end;
}
}
}
area(Promoted)
{
group(Category_Process)
{
Caption = 'Process';
actionref("&Navigate_Promoted"; "&Navigate")
{
}
actionref(CancelCrMemo_Promoted; CancelCrMemo)
{
}
actionref(ShowInvoice_Promoted; ShowInvoice)
{
}
}
group(Category_Category6)
{
Caption = 'Print/Send', Comment = 'Generated from the PromotedActionCategories property index 5.';
actionref("&Print_Promoted"; "&Print")
{
}
actionref(AttachAsPDF_Promoted; AttachAsPDF)
{
}
}
group(Category_Category4)
{
Caption = 'Cancel', Comment = 'Generated from the PromotedActionCategories property index 3.';
}
group(Category_Category7)
{
Caption = 'Credit Memo', Comment = 'Generated from the PromotedActionCategories property index 6.';
actionref(Dimensions_Promoted; Dimensions)
{
}
actionref(Statistics_Promoted; Statistics)
{
}
actionref("Co&mments_Promoted"; "Co&mments")
{
}
actionref(DocAttach_Promoted; DocAttach)
{
}
actionref(Approvals_Promoted; Approvals)
{
}
actionref(Vendor_Promoted; Vendor)
{
}
}
group("Category_Incoming Document")
{
Caption = 'Incoming Document';
actionref(IncomingDocAttachFile_Promoted; IncomingDocAttachFile)
{
}
actionref(SelectIncomingDoc_Promoted; SelectIncomingDoc)
{
}
actionref(IncomingDocCard_Promoted; IncomingDocCard)
{
}
}
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.';
}
}
}
trigger OnAfterGetCurrRecord()
var
IncomingDocument: Record "Incoming Document";
begin
HasIncomingDocument := IncomingDocument.PostedDocExists(Rec."No.", Rec."Posting Date");
CurrPage.IncomingDocAttachFactBox.PAGE.LoadDataFromRecord(Rec);
end;
trigger OnAfterGetRecord()
begin
BuyFromContact.GetOrClear(Rec."Buy-from Contact No.");
PayToContact.GetOrClear(Rec."Pay-to Contact No.");
end;
trigger OnOpenPage()
var
OfficeMgt: Codeunit "Office Management";
VATReportingDateMgt: Codeunit "VAT Reporting Date Mgt";
begin
Rec.SetSecurityFilterOnRespCenter();
IsOfficeAddin := OfficeMgt.IsAvailable();
ActivateFields();
VATDateEnabled := VATReportingDateMgt.IsVATDateEnabled();
end;
var
PurchCrMemoHeader: Record "Purch. Cr. Memo Hdr.";
BuyFromContact: Record Contact;
PayToContact: Record Contact;
FormatAddress: Codeunit "Format Address";
ChangeExchangeRate: Page "Change Exchange Rate";
HasIncomingDocument: Boolean;
IsOfficeAddin: Boolean;
IsBuyFromCountyVisible: Boolean;
IsPayToCountyVisible: Boolean;
IsShipToCountyVisible: Boolean;
VATDateEnabled: Boolean;
local procedure ActivateFields()
begin
IsBuyFromCountyVisible := FormatAddress.UseCounty(Rec."Buy-from Country/Region Code");
IsPayToCountyVisible := FormatAddress.UseCounty(Rec."Pay-to Country/Region Code");
IsShipToCountyVisible := FormatAddress.UseCounty(Rec."Ship-to Country/Region Code");
end;
}