Page 5936 Service Credit Memo Subform
src/Layers/W1/BaseApp/Service/Document/ServiceCreditMemoSubform.Page.al690 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.Service.Document;using Microsoft.Finance.Dimension;using Microsoft.Foundation.Attachment;using Microsoft.Foundation.ExtendedText;using Microsoft.Inventory.Availability;using Microsoft.Inventory.Item;using Microsoft.Inventory.Item.Catalog;using Microsoft.Inventory.Location;using Microsoft.Utilities;page 5936 "Service Credit Memo Subform"{ AutoSplitKey = true; Caption = 'Lines'; DelayedInsert = true; LinksAllowed = false; MultipleNewLines = true; PageType = ListPart; SourceTable = "Service Line"; SourceTableView = where("Document Type" = filter("Credit Memo")); layout { area(content) { repeater(Control1) { ShowCaption = false; field(Type; Rec.Type) { ApplicationArea = Service; trigger OnValidate() begin NoOnAfterValidate(); end; } field("No."; Rec."No.") { ApplicationArea = Service; trigger OnValidate() var Item: Record "Item"; begin Rec.ShowShortcutDimCode(ShortcutDimCode); NoOnAfterValidate(); if Rec."Variant Code" = '' then VariantCodeMandatory := Item.IsVariantMandatory(Rec.Type = Rec.Type::Item, Rec."No."); end; } field("Item Reference No."; Rec."Item Reference No.") { AccessByPermission = tabledata "Item Reference" = R; ApplicationArea = Service, ItemReferences; QuickEntry = false; Visible = ItemReferenceVisible; trigger OnLookup(var Text: Text): Boolean var ServItemReferenceMgt: Codeunit "Serv. Item Reference Mgt."; begin ServItemReferenceMgt.ServiceReferenceNoLookUp(Rec); InsertExtendedText(false); NoOnAfterValidate(); CurrPage.Update(); end; trigger OnValidate() begin NoOnAfterValidate(); CurrPage.Update(); end; } field("Variant Code"; Rec."Variant Code") { ApplicationArea = Planning; Visible = false; ShowMandatory = VariantCodeMandatory; trigger OnValidate() var Item: Record "Item"; begin if Rec."Variant Code" = '' then VariantCodeMandatory := Item.IsVariantMandatory(Rec.Type = Rec.Type::Item, Rec."No."); end; } field(Nonstock; Rec.Nonstock) { ApplicationArea = Service; Visible = false; } field("Gen. Bus. Posting Group"; Rec."Gen. Bus. Posting Group") { ApplicationArea = Service; Visible = false; } field("Gen. Prod. Posting Group"; Rec."Gen. Prod. Posting Group") { ApplicationArea = Service; Visible = false; } field("VAT Bus. Posting Group"; Rec."VAT Bus. Posting Group") { ApplicationArea = Service; Visible = false; } field("VAT Prod. Posting Group"; Rec."VAT Prod. Posting Group") { ApplicationArea = Service; Visible = false; } field(Description; Rec.Description) { ApplicationArea = Service; } field("Description 2"; Rec."Description 2") { ApplicationArea = Service; Importance = Additional; Visible = false; } field("Return Reason Code"; Rec."Return Reason Code") { ApplicationArea = Service; Visible = false; } field("Location Code"; Rec."Location Code") { ApplicationArea = Location; Visible = true; } field("Bin Code"; Rec."Bin Code") { ApplicationArea = Warehouse; Visible = false; } field(Reserve; Rec.Reserve) { ApplicationArea = Reservation; Visible = false; trigger OnValidate() begin ReserveOnAfterValidate(); end; } field(Quantity; Rec.Quantity) { ApplicationArea = Service; BlankZero = true; trigger OnValidate() begin QuantityOnAfterValidate(); end; } field("Reserved Quantity"; Rec."Reserved Quantity") { ApplicationArea = Reservation; BlankZero = true; Visible = false; trigger OnDrillDown() begin CurrPage.SaveRecord(); Commit(); Rec.ShowReservationEntries(true); UpdateForm(true); end; } field("Unit of Measure Code"; Rec."Unit of Measure Code") { ApplicationArea = Service; trigger OnValidate() begin UnitofMeasureCodeOnAfterValidate(); end; } field("Unit of Measure"; Rec."Unit of Measure") { ApplicationArea = Service; Visible = false; } field("Unit Cost (LCY)"; Rec."Unit Cost (LCY)") { ApplicationArea = Service; ToolTip = 'Specifies the cost, in LCY, of one unit of the item or resource on the line.'; Visible = false; } field("Unit Price"; Rec."Unit Price") { ApplicationArea = Service; BlankZero = true; } field("Tax Liable"; Rec."Tax Liable") { ApplicationArea = SalesTax; Editable = false; ToolTip = 'Specifies that items, resources, or costs on the current credit memo line are liable for sales tax.'; Visible = false; } field("Tax Area Code"; Rec."Tax Area Code") { ApplicationArea = SalesTax; Visible = false; } field("Tax Group Code"; Rec."Tax Group Code") { ApplicationArea = SalesTax; } field("Line Amount"; Rec."Line Amount") { ApplicationArea = Service; } field("Line Discount %"; Rec."Line Discount %") { ApplicationArea = Service; BlankZero = true; } field("Line Discount Amount"; Rec."Line Discount Amount") { ApplicationArea = Service; Visible = false; } field("Allow Invoice Disc."; Rec."Allow Invoice Disc.") { ApplicationArea = Service; Visible = false; } field("Inv. Discount Amount"; Rec."Inv. Discount Amount") { ApplicationArea = Service; Visible = false; } field("Serv. Price Adjmt. Gr. Code"; Rec."Serv. Price Adjmt. Gr. Code") { ApplicationArea = Service; Visible = false; } field("Work Type Code"; Rec."Work Type Code") { ApplicationArea = Service; Visible = false; } field("Contract No."; Rec."Contract No.") { ApplicationArea = Service; Visible = false; } field("Service Item No."; Rec."Service Item No.") { ApplicationArea = Service; Visible = false; } field("Appl.-from Item Entry"; Rec."Appl.-from Item Entry") { ApplicationArea = Service; Visible = false; } field("Shortcut Dimension 1 Code"; Rec."Shortcut Dimension 1 Code") { ApplicationArea = Dimensions; Visible = DimVisible1; } field("Shortcut Dimension 2 Code"; Rec."Shortcut Dimension 2 Code") { ApplicationArea = Dimensions; Visible = DimVisible2; } field("ShortcutDimCode[3]"; ShortcutDimCode[3]) { ApplicationArea = Dimensions; CaptionClass = '1,2,3'; TableRelation = "Dimension Value".Code where("Global Dimension No." = const(3), "Dimension Value Type" = const(Standard), Blocked = const(false)); Visible = DimVisible3; trigger OnValidate() begin Rec.ValidateShortcutDimCode(3, ShortcutDimCode[3]); end; } field("ShortcutDimCode[4]"; ShortcutDimCode[4]) { ApplicationArea = Dimensions; CaptionClass = '1,2,4'; TableRelation = "Dimension Value".Code where("Global Dimension No." = const(4), "Dimension Value Type" = const(Standard), Blocked = const(false)); Visible = DimVisible4; trigger OnValidate() begin Rec.ValidateShortcutDimCode(4, ShortcutDimCode[4]); end; } field("ShortcutDimCode[5]"; ShortcutDimCode[5]) { ApplicationArea = Dimensions; CaptionClass = '1,2,5'; TableRelation = "Dimension Value".Code where("Global Dimension No." = const(5), "Dimension Value Type" = const(Standard), Blocked = const(false)); Visible = DimVisible5; trigger OnValidate() begin Rec.ValidateShortcutDimCode(5, ShortcutDimCode[5]); end; } field("ShortcutDimCode[6]"; ShortcutDimCode[6]) { ApplicationArea = Dimensions; CaptionClass = '1,2,6'; TableRelation = "Dimension Value".Code where("Global Dimension No." = const(6), "Dimension Value Type" = const(Standard), Blocked = const(false)); Visible = DimVisible6; trigger OnValidate() begin Rec.ValidateShortcutDimCode(6, ShortcutDimCode[6]); end; } field("ShortcutDimCode[7]"; ShortcutDimCode[7]) { ApplicationArea = Dimensions; CaptionClass = '1,2,7'; TableRelation = "Dimension Value".Code where("Global Dimension No." = const(7), "Dimension Value Type" = const(Standard), Blocked = const(false)); Visible = DimVisible7; trigger OnValidate() begin Rec.ValidateShortcutDimCode(7, ShortcutDimCode[7]); end; } field("ShortcutDimCode[8]"; ShortcutDimCode[8]) { ApplicationArea = Dimensions; CaptionClass = '1,2,8'; TableRelation = "Dimension Value".Code where("Global Dimension No." = const(8), "Dimension Value Type" = const(Standard), Blocked = const(false)); Visible = DimVisible8; trigger OnValidate() begin Rec.ValidateShortcutDimCode(8, ShortcutDimCode[8]); end; } } } } actions { area(processing) { group("F&unctions") { Caption = 'F&unctions'; Image = "Action"; action("Insert &Ext. Texts") { AccessByPermission = TableData "Extended Text Header" = R; ApplicationArea = Service; Caption = 'Insert &Ext. Texts'; Image = Text; ToolTip = 'Insert the extended item description that is set up for the item that is being processed on the line.'; trigger OnAction() begin InsertExtendedText(true); end; } } group("&Line") { Caption = '&Line'; Image = Line; group("Item Availability by") { Caption = 'Item Availability by'; Image = ItemAvailability; action("Event") { ApplicationArea = Service; Caption = 'Event'; Image = "Event"; ToolTip = 'View how the actual and the projected available balance of an item will develop over time according to supply and demand events.'; trigger OnAction() begin ServAvailabilityMgt.ShowItemAvailabilityFromServLine(Rec, "Item Availability Type"::"Event"); end; } action(Period) { ApplicationArea = Service; Caption = 'Period'; Image = Period; ToolTip = 'View the projected quantity of the item over time according to time periods, such as day, week, or month.'; trigger OnAction() begin ServAvailabilityMgt.ShowItemAvailabilityFromServLine(Rec, "Item Availability Type"::"Period"); end; } action(Variant) { ApplicationArea = Planning; Caption = 'Variant'; Image = ItemVariant; ToolTip = 'View or edit the item''s variants. Instead of setting up each color of an item as a separate item, you can set up the various colors as variants of the item.'; trigger OnAction() begin ServAvailabilityMgt.ShowItemAvailabilityFromServLine(Rec, "Item Availability Type"::Variant); end; } action(Location) { AccessByPermission = TableData Location = R; ApplicationArea = Service; Caption = 'Location'; Image = Warehouse; ToolTip = 'View the actual and projected quantity of the item per location.'; trigger OnAction() begin ServAvailabilityMgt.ShowItemAvailabilityFromServLine(Rec, "Item Availability Type"::Location); end; } action(Lot) { ApplicationArea = ItemTracking; Caption = 'Lot'; Image = LotInfo; RunObject = Page "Item Availability by Lot No."; RunPageLink = "No." = field("No."), "Location Filter" = field("Location Code"), "Variant Filter" = field("Variant Code"); ToolTip = 'View the current and projected quantity of the item in each lot.'; } action("BOM Level") { ApplicationArea = Service; Caption = 'BOM Level'; Image = BOMLevel; ToolTip = 'View availability figures for items on bills of materials that show how many units of a parent item you can make based on the availability of child items.'; trigger OnAction() begin ServAvailabilityMgt.ShowItemAvailabilityFromServLine(Rec, "Item Availability Type"::BOM); end; } } 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(ItemTrackingLines) { ApplicationArea = ItemTracking; Caption = 'Item &Tracking Lines'; Image = ItemTrackingLines; ShortCutKey = 'Ctrl+Alt+I'; ToolTip = 'View or edit serial, lot and package numbers that are assigned to the item on the document or journal line.'; trigger OnAction() begin Rec.OpenItemTrackingLines(); end; } action(DocAttach) { ApplicationArea = Service; 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; } } group(Errors) { Caption = 'Issues'; Image = ErrorLog; Visible = BackgroundErrorCheck; ShowAs = SplitButton; action(ShowLinesWithErrors) { ApplicationArea = Basic, Suite; Caption = 'Show Lines with Issues'; Image = Error; Visible = BackgroundErrorCheck; Enabled = not ShowAllLinesEnabled; ToolTip = 'View a list of service lines that have issues before you post the document.'; trigger OnAction() begin Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled); end; } action(ShowAllLines) { ApplicationArea = Basic, Suite; Caption = 'Show All Lines'; Image = ExpandAll; Visible = BackgroundErrorCheck; Enabled = ShowAllLinesEnabled; ToolTip = 'View all sales service, including lines with and without issues.'; trigger OnAction() begin Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled); end; } } } } trigger OnAfterGetRecord() var Item: Record Item; begin Rec.ShowShortcutDimCode(ShortcutDimCode); if Rec."Variant Code" = '' then VariantCodeMandatory := Item.IsVariantMandatory(Rec.Type = Rec.Type::Item, Rec."No."); end; trigger OnDeleteRecord(): Boolean var ServiceLineReserve: Codeunit "Service Line-Reserve"; begin if (Rec.Quantity <> 0) and Rec.ItemExists(Rec."No.") then begin Commit(); if not ServiceLineReserve.DeleteLineConfirm(Rec) then exit(false); ServiceLineReserve.DeleteLine(Rec); end; end; trigger OnNewRecord(BelowxRec: Boolean) begin Rec.Type := xRec.Type; Clear(ShortcutDimCode); end; trigger OnOpenPage() var DocumentErrorsMgt: Codeunit "Document Errors Mgt."; begin BackgroundErrorCheck := DocumentErrorsMgt.BackgroundValidationEnabled(); SetDimensionsVisibility(); SetItemReferenceVisibility(); end; var ServiceTransferExtText: Codeunit "Service Transfer Ext. Text"; ServAvailabilityMgt: Codeunit "Serv. Availability Mgt."; BackgroundErrorCheck: Boolean; ItemReferenceVisible: Boolean; ShowAllLinesEnabled: Boolean; VariantCodeMandatory: Boolean; protected var ShortcutDimCode: array[8] of Code[20]; DimVisible1: Boolean; DimVisible2: Boolean; DimVisible3: Boolean; DimVisible4: Boolean; DimVisible5: Boolean; DimVisible6: Boolean; DimVisible7: Boolean; DimVisible8: Boolean; procedure ApproveCalcInvDisc() begin CODEUNIT.Run(CODEUNIT::"Service-Disc. (Yes/No)", Rec); end; procedure InsertExtendedText(Unconditionally: Boolean) begin OnBeforeInsertExtendedText(Rec); if ServiceTransferExtText.ServCheckIfAnyExtText(Rec, Unconditionally) then begin CurrPage.SaveRecord(); ServiceTransferExtText.InsertServExtText(Rec); end; if ServiceTransferExtText.MakeUpdate() then UpdateForm(true); end; procedure UpdateForm(SetSaveRecord: Boolean) begin CurrPage.Update(SetSaveRecord); end; local procedure SetItemReferenceVisibility() var ItemReference: Record "Item Reference"; begin ItemReferenceVisible := not ItemReference.IsEmpty(); end; protected procedure NoOnAfterValidate() begin InsertExtendedText(false); end; protected procedure ReserveOnAfterValidate() begin if (Rec.Reserve = Rec.Reserve::Always) and (Rec."Outstanding Qty. (Base)" <> 0) then begin CurrPage.SaveRecord(); Rec.AutoReserve(); end; end; protected procedure QuantityOnAfterValidate() begin if Rec.Reserve = Rec.Reserve::Always then begin CurrPage.SaveRecord(); Rec.AutoReserve(); end; end; protected procedure UnitofMeasureCodeOnAfterValidate() begin if Rec.Reserve = Rec.Reserve::Always then begin CurrPage.SaveRecord(); Rec.AutoReserve(); end; end; local procedure SetDimensionsVisibility() var DimMgt: Codeunit DimensionManagement; begin DimVisible1 := false; DimVisible2 := false; DimVisible3 := false; DimVisible4 := false; DimVisible5 := false; DimVisible6 := false; DimVisible7 := false; DimVisible8 := false; DimMgt.UseShortcutDims( DimVisible1, DimVisible2, DimVisible3, DimVisible4, DimVisible5, DimVisible6, DimVisible7, DimVisible8); Clear(DimMgt); end; [IntegrationEvent(false, false)] local procedure OnBeforeInsertExtendedText(var ServiceLine: Record "Service Line") begin end;}