Page 54 Purchase Order Subform, source in 29
Source29
src/Layers/W1/BaseApp/Purchases/Document/PurchaseOrderSubform.Page.al2022 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.Finance.AllocationAccount;
using Microsoft.Finance.AllocationAccount.Purchase;
using Microsoft.Finance.Currency;
using Microsoft.Finance.Deferral;
using Microsoft.Finance.Dimension;
using Microsoft.Finance.VAT.Calculation;
using Microsoft.Foundation.Attachment;
using Microsoft.Foundation.ExtendedText;
using Microsoft.Foundation.Navigate;
using Microsoft.Inventory.Availability;
using Microsoft.Inventory.BOM;
using Microsoft.Inventory.Item;
using Microsoft.Inventory.Item.Catalog;
using Microsoft.Inventory.Location;
using Microsoft.Inventory.Setup;
using Microsoft.Inventory.Tracking;
using Microsoft.Purchases.History;
using Microsoft.Purchases.Setup;
using Microsoft.Sales.Document;
using Microsoft.Sales.History;
using Microsoft.Utilities;
using System.Environment.Configuration;
using System.Integration.Excel;
using System.Utilities;
page 54 "Purchase Order Subform"
{
AutoSplitKey = true;
Caption = 'Lines';
DelayedInsert = true;
LinksAllowed = false;
MultipleNewLines = true;
PageType = ListPart;
SourceTable = "Purchase Line";
SourceTableView = where("Document Type" = filter(Order));
layout
{
area(content)
{
repeater(Control1)
{
ShowCaption = false;
field(Type; Rec.Type)
{
ApplicationArea = Advanced;
trigger OnValidate()
begin
NoOnAfterValidate();
UpdateEditableOnRow();
UpdateTypeText();
DeltaUpdateTotals();
end;
}
field(FilteredTypeField; TypeAsText)
{
ApplicationArea = Basic, Suite;
Caption = 'Type';
Editable = CurrPageIsEditable;
LookupPageID = "Option Lookup List";
TableRelation = "Option Lookup Buffer"."Option Caption" where("Lookup Type" = const(Purchases));
ToolTip = 'Specifies the type of transaction that will be posted with the document line. If you select Comment, then you can enter any text in the Description field, such as a message to a customer. ';
Visible = IsFoundation;
trigger OnValidate()
begin
TempOptionLookupBuffer.SetCurrentType(Rec.Type.AsInteger());
if TempOptionLookupBuffer.AutoCompleteLookup(TypeAsText, TempOptionLookupBuffer."Lookup Type"::Purchases) then
Rec.Validate(Type, TempOptionLookupBuffer.ID);
TempOptionLookupBuffer.ValidateOption(TypeAsText);
UpdateEditableOnRow();
UpdateTypeText();
DeltaUpdateTotals();
end;
}
field("No."; Rec."No.")
{
ApplicationArea = Suite;
ShowMandatory = not IsCommentLine;
ToolTip = 'Specifies what you are buying, such as a product or a fixed asset. You’ll see different lists of things to choose from depending on your choice in the Type field.';
trigger OnValidate()
begin
Rec.ShowShortcutDimCode(ShortcutDimCode);
NoOnAfterValidate();
UpdateTypeText();
DeltaUpdateTotals();
CurrPage.Update();
end;
}
field("Item Reference No."; Rec."Item Reference No.")
{
AccessByPermission = tabledata "Item Reference" = R;
ApplicationArea = Suite, ItemReferences;
QuickEntry = false;
Visible = ItemReferenceVisible;
trigger OnLookup(var Text: Text): Boolean
var
ItemReferenceMgt: Codeunit "Item Reference Management";
begin
PurchaseHeader.Get(Rec."Document Type", Rec."Document No.");
ItemReferenceMgt.PurchaseReferenceNoLookUp(Rec, PurchaseHeader);
InsertExtendedText(false);
NoOnAfterValidate();
DeltaUpdateTotals();
OnItemReferenceNoOnLookup(Rec);
CurrPage.Update();
end;
trigger OnValidate()
begin
InsertExtendedText(false);
NoOnAfterValidate();
DeltaUpdateTotals();
CurrPage.Update();
end;
}
field("IC Partner Code"; Rec."IC Partner Code")
{
ApplicationArea = Intercompany;
Visible = false;
}
field("IC Partner Ref. Type"; Rec."IC Partner Ref. Type")
{
ApplicationArea = Intercompany;
Visible = false;
}
field("IC Partner Reference"; Rec."IC Partner Reference")
{
ApplicationArea = Intercompany;
Visible = false;
}
field("Variant Code"; Rec."Variant Code")
{
ApplicationArea = Planning;
ShowMandatory = VariantCodeMandatory;
Visible = false;
trigger OnValidate()
var
Item: Record "Item";
begin
DeltaUpdateTotals();
if Rec."Variant Code" = '' then
VariantCodeMandatory := Item.IsVariantMandatory(Rec.Type = Rec.Type::Item, Rec."No.");
end;
}
field(Nonstock; Rec.Nonstock)
{
ApplicationArea = Suite;
Visible = false;
}
field("Gen. Bus. Posting Group"; Rec."Gen. Bus. Posting Group")
{
ApplicationArea = Suite;
Visible = false;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Gen. Prod. Posting Group"; Rec."Gen. Prod. Posting Group")
{
ApplicationArea = Suite;
Visible = false;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("VAT Bus. Posting Group"; Rec."VAT Bus. Posting Group")
{
ApplicationArea = Suite;
Visible = false;
trigger OnValidate()
begin
ForceTotalsCalculation();
DeltaUpdateTotals();
end;
}
field("VAT Prod. Posting Group"; Rec."VAT Prod. Posting Group")
{
ApplicationArea = Suite;
Visible = false;
trigger OnValidate()
begin
ForceTotalsCalculation();
DeltaUpdateTotals();
end;
}
field(Description; Rec.Description)
{
ApplicationArea = Suite;
ToolTip = 'Describes what is being purchased. The suggested text comes from the item itself. You can change it to suit your needs for this document. If you change it here, the source of the text will not change. If the line''s Type field is set to Comment, you can use this field to write the comment, and leave the other fields empty.';
trigger OnValidate()
begin
Rec.RestoreLookupSelection();
if Rec."No." <> xRec."No." then
NoOnAfterValidate();
if Rec."No." = xRec."No." then
exit;
Rec.ShowShortcutDimCode(ShortcutDimCode);
DeltaUpdateTotals();
end;
trigger OnAfterLookup(Selected: RecordRef)
begin
Rec.SaveLookupSelection(Selected);
end;
}
field("Description 2"; Rec."Description 2")
{
ApplicationArea = Suite;
Importance = Additional;
Visible = false;
}
field("Receipt on Invoice"; Rec."Receipt on Invoice")
{
ApplicationArea = All;
Visible = false;
}
field("Drop Shipment"; Rec."Drop Shipment")
{
ApplicationArea = Suite;
Visible = false;
}
field("Return Reason Code"; Rec."Return Reason Code")
{
ApplicationArea = Suite;
Visible = false;
}
field("Location Code"; Rec."Location Code")
{
ApplicationArea = Location;
Editable = not IsBlankNumber;
Enabled = not IsBlankNumber;
ToolTip = 'Specifies a code for the location where you want the items to be placed when they are received.';
trigger OnValidate()
begin
Rec.ShowShortcutDimCode(ShortcutDimCode);
DeltaUpdateTotals();
end;
}
field("Bin Code"; Rec."Bin Code")
{
ApplicationArea = Warehouse;
Visible = true;
}
field(Quantity; Rec.Quantity)
{
ApplicationArea = Suite;
BlankZero = true;
Editable = not IsBlankNumber;
Enabled = not IsBlankNumber;
ShowMandatory = (Rec.Type <> Rec.Type::" ") and (Rec."No." <> '');
ToolTip = 'Specifies the quantity of what you''re buying. The number is based on the unit chosen in the Unit of Measure Code field.';
trigger OnValidate()
begin
CurrPage.SaveRecord();
DeltaUpdateTotals();
SetItemChargeFieldsStyle();
if PurchasesPayablesSetup."Calc. Inv. Discount" and (Rec.Quantity = 0) then
CurrPage.Update(false);
end;
}
field("Reserved Quantity"; Rec."Reserved Quantity")
{
ApplicationArea = Reservation;
BlankZero = true;
}
field("Job Remaining Qty."; Rec."Job Remaining Qty.")
{
ApplicationArea = Jobs;
BlankZero = true;
Visible = false;
}
field("Unit of Measure Code"; Rec."Unit of Measure Code")
{
ApplicationArea = Suite;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Unit of Measure"; Rec."Unit of Measure")
{
ApplicationArea = Suite;
Visible = false;
}
field("Direct Unit Cost"; Rec."Direct Unit Cost")
{
ApplicationArea = Suite;
BlankZero = true;
Editable = not IsBlankNumber;
Enabled = not IsBlankNumber;
ShowMandatory = (Rec.Type <> Rec.Type::" ") and (Rec."No." <> '');
ToolTip = 'Specifies the price of one unit of what you''re buying.';
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Indirect Cost %"; Rec."Indirect Cost %")
{
ApplicationArea = Suite;
Visible = false;
}
field("Unit Cost (LCY)"; Rec."Unit Cost (LCY)")
{
ApplicationArea = Suite;
ToolTip = 'Specifies the unit cost of the item on the line.';
Visible = false;
}
field("Unit Price (LCY)"; Rec."Unit Price (LCY)")
{
ApplicationArea = Suite;
BlankZero = true;
ToolTip = 'Specifies the price, in LCY, for one unit of the item.';
Visible = false;
}
field("Tax Liable"; Rec."Tax Liable")
{
ApplicationArea = SalesTax;
Editable = false;
Visible = false;
}
field("Tax Area Code"; Rec."Tax Area Code")
{
ApplicationArea = SalesTax;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Tax Group Code"; Rec."Tax Group Code")
{
ApplicationArea = SalesTax;
ShowMandatory = Rec."Tax Area Code" <> '';
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Use Tax"; Rec."Use Tax")
{
ApplicationArea = SalesTax;
Visible = false;
}
field("Line Discount %"; Rec."Line Discount %")
{
ApplicationArea = Suite;
BlankZero = true;
Editable = not IsBlankNumber;
Enabled = not IsBlankNumber;
Visible = false;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Line Amount"; Rec."Line Amount")
{
ApplicationArea = Suite;
BlankZero = true;
Editable = not IsBlankNumber;
Enabled = not IsBlankNumber;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Line Discount Amount"; Rec."Line Discount Amount")
{
ApplicationArea = Suite;
Visible = false;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field(NonDeductibleVATBase; Rec."Non-Deductible VAT Base")
{
ApplicationArea = Basic, Suite;
Visible = ShowNonDedVATInLines;
}
field(NonDeductibleVATAmount; Rec."Non-Deductible VAT Amount")
{
ApplicationArea = Basic, Suite;
Visible = ShowNonDedVATInLines;
}
field("Prepayment %"; Rec."Prepayment %")
{
ApplicationArea = Prepayments;
Visible = false;
}
field("Prepmt. Line Amount"; Rec."Prepmt. Line Amount")
{
ApplicationArea = Prepayments;
Visible = false;
}
field("Prepmt. Amt. Inv."; Rec."Prepmt. Amt. Inv.")
{
ApplicationArea = Prepayments;
Visible = false;
}
field("Allow Invoice Disc."; Rec."Allow Invoice Disc.")
{
ApplicationArea = Suite;
Visible = false;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Inv. Discount Amount"; Rec."Inv. Discount Amount")
{
ApplicationArea = Suite;
Visible = false;
trigger OnValidate()
begin
DeltaUpdateTotals();
end;
}
field("Inv. Disc. Amount to Invoice"; Rec."Inv. Disc. Amount to Invoice")
{
ApplicationArea = Suite;
Visible = false;
}
field("Qty. to Receive"; Rec."Qty. to Receive")
{
ApplicationArea = Suite;
BlankZero = true;
trigger OnValidate()
begin
SetItemChargeFieldsStyle();
CurrPage.Update();
end;
}
field("Quantity Received"; Rec."Quantity Received")
{
ApplicationArea = Suite;
BlankZero = true;
trigger OnDrillDown()
var
PurchRcptLine: Record "Purch. Rcpt. Line";
begin
PurchRcptLine.SetCurrentKey("Document No.", "No.", "Planned Receipt Date");
PurchRcptLine.SetRange("Order No.", Rec."Document No.");
PurchRcptLine.SetRange("Order Line No.", Rec."Line No.");
PurchRcptLine.SetFilter(Quantity, '<>%1', 0);
PAGE.RunModal(0, PurchRcptLine);
end;
}
field("Qty. to Invoice"; Rec."Qty. to Invoice")
{
ApplicationArea = Suite;
BlankZero = true;
trigger OnValidate()
begin
SetItemChargeFieldsStyle();
CurrPage.Update();
end;
}
field("Quantity Invoiced"; Rec."Quantity Invoiced")
{
ApplicationArea = Suite;
BlankZero = true;
trigger OnDrillDown()
var
PurchInvLine: Record "Purch. Inv. Line";
PostedMatchedOrderLine: Record "Posted Matched Order Line";
PurchInvLineSystemIDFilter: Text;
NullGuid: Guid;
begin
PurchInvLine.SetCurrentKey("Document No.", "No.", "Expected Receipt Date");
PurchInvLine.SetRange("Order No.", Rec."Document No.");
PurchInvLine.SetRange("Order Line No.", Rec."Line No.");
PurchInvLine.SetFilter(Quantity, '<>%1', 0);
if PurchInvLine.FindSet() then
repeat
PurchInvLineSystemIDFilter += Format(PurchInvLine.SystemId) + '|';
until PurchInvLine.Next() = 0;
PostedMatchedOrderLine.SetRange("Matched Order Line SystemId", Rec.SystemId);
if PostedMatchedOrderLine.FindSet() then
repeat
PurchInvLineSystemIDFilter += Format(PostedMatchedOrderLine."Document Line SystemId") + '|';
until PostedMatchedOrderLine.Next() = 0;
if PurchInvLineSystemIDFilter <> '' then
PurchInvLineSystemIDFilter := CopyStr(PurchInvLineSystemIDFilter, 1, StrLen(PurchInvLineSystemIDFilter) - 1)
else
PurchInvLineSystemIDFilter := NullGuid;
PurchInvLine.Reset();
PurchInvLine.SetFilter(SystemId, PurchInvLineSystemIDFilter);
Page.RunModal(0, PurchInvLine);
end;
}
field("Matched Inv./Cr. Memo Lines"; Rec."Matched Inv./Cr. Memo Lines")
{
ApplicationArea = Basic, Suite;
Caption = 'Matched Invoice Lines';
ToolTip = 'Specifies the number of purchase invoice lines to which this purchase order line is matched.';
trigger OnDrillDown()
var
MatchedOrderLineMgmt: Codeunit "Matched Order Line Mgmt.";
begin
MatchedOrderLineMgmt.ShowMatchedInvoiceLines(Rec);
end;
}
field("Prepmt Amt to Deduct"; Rec."Prepmt Amt to Deduct")
{
ApplicationArea = Prepayments;
Visible = false;
}
field("Prepmt Amt Deducted"; Rec."Prepmt Amt Deducted")
{
ApplicationArea = Prepayments;
Visible = false;
}
field("Allow Item Charge Assignment"; Rec."Allow Item Charge Assignment")
{
ApplicationArea = ItemCharges;
Visible = false;
}
field("Qty. to Assign"; Rec."Qty. to Assign")
{
ApplicationArea = ItemCharges;
StyleExpr = ItemChargeStyleExpression;
trigger OnDrillDown()
begin
CurrPage.SaveRecord();
Rec.ShowItemChargeAssgnt();
UpdateForm(false);
end;
}
field("Item Charge Qty. to Handle"; Rec."Item Charge Qty. to Handle")
{
ApplicationArea = ItemCharges;
QuickEntry = false;
StyleExpr = ItemChargeToHandleStyleExpression;
trigger OnDrillDown()
begin
CurrPage.SaveRecord();
Rec.ShowItemChargeAssgnt();
UpdateForm(false);
end;
}
field("Qty. Assigned"; Rec."Qty. Assigned")
{
ApplicationArea = ItemCharges;
BlankZero = true;
trigger OnDrillDown()
begin
CurrPage.SaveRecord();
Rec.ShowItemChargeAssgnt();
UpdateForm(false);
end;
}
field("Allocation Account No."; Rec."Selected Alloc. Account No.")
{
ApplicationArea = All;
Caption = 'Allocation Account No.';
Visible = UseAllocationAccountNumber;
trigger OnValidate()
var
PurchaseAllocAccMgt: Codeunit "Purchase Alloc. Acc. Mgt.";
begin
PurchaseAllocAccMgt.VerifySelectedAllocationAccountNo(Rec);
end;
}
field("Job No."; Rec."Job No.")
{
ApplicationArea = Jobs;
Visible = false;
trigger OnValidate()
begin
Rec.ShowShortcutDimCode(ShortcutDimCode);
end;
}
field("Job Task No."; Rec."Job Task No.")
{
ApplicationArea = Jobs;
Visible = false;
trigger OnValidate()
begin
Rec.ShowShortcutDimCode(ShortcutDimCode);
end;
}
field("Job Planning Line No."; Rec."Job Planning Line No.")
{
ApplicationArea = Jobs;
Visible = false;
}
field("Job Line Type"; Rec."Job Line Type")
{
ApplicationArea = Jobs;
ToolTip = 'Specifies the type of planning line that was created when the project ledger entry is posted from the purchase line. If the field is empty, no planning lines were created for this entry.';
Visible = false;
}
field("Job Unit Price"; Rec."Job Unit Price")
{
ApplicationArea = Jobs;
Visible = false;
}
field("Job Line Amount"; Rec."Job Line Amount")
{
ApplicationArea = Jobs;
Visible = false;
}
field("Job Line Discount Amount"; Rec."Job Line Discount Amount")
{
ApplicationArea = Jobs;
Visible = false;
}
field("Job Line Discount %"; Rec."Job Line Discount %")
{
ApplicationArea = Jobs;
Visible = false;
}
field("Job Total Price"; Rec."Job Total Price")
{
ApplicationArea = Jobs;
Visible = false;
}
field("Job Unit Price (LCY)"; Rec."Job Unit Price (LCY)")
{
ApplicationArea = Jobs;
ToolTip = 'Specifies the sales price per unit that applies to the item or general ledger expense that will be posted.';
Visible = false;
}
field("Job Total Price (LCY)"; Rec."Job Total Price (LCY)")
{
ApplicationArea = Jobs;
ToolTip = 'Specifies the gross amount of the line, in the local currency.';
Visible = false;
}
field("Job Line Amount (LCY)"; Rec."Job Line Amount (LCY)")
{
ApplicationArea = Jobs;
ToolTip = 'Specifies the line amount of the project ledger entry that is related to the purchase line.';
Visible = false;
}
field("Job Line Disc. Amount (LCY)"; Rec."Job Line Disc. Amount (LCY)")
{
ApplicationArea = Jobs;
ToolTip = 'Specifies the line discount amount of the project ledger entry that is related to the purchase line.';
Visible = false;
}
field("Requested Receipt Date"; Rec."Requested Receipt Date")
{
ApplicationArea = Suite;
Visible = false;
}
field("Promised Receipt Date"; Rec."Promised Receipt Date")
{
ApplicationArea = OrderPromising;
Visible = true;
}
field("Planned Receipt Date"; Rec."Planned Receipt Date")
{
ApplicationArea = Suite;
}
field("Expected Receipt Date"; Rec."Expected Receipt Date")
{
ApplicationArea = Suite;
ToolTip = 'Specifies the date you expect the items to be available in your warehouse. If you leave the field blank, it will be calculated as follows: Planned Receipt Date + Safety Lead Time + Inbound Warehouse Handling Time = Expected Receipt Date.';
}
field("Order Date"; Rec."Order Date")
{
ApplicationArea = Suite;
Visible = false;
}
field("Lead Time Calculation"; Rec."Lead Time Calculation")
{
ApplicationArea = Suite;
Visible = false;
}
field("Planning Flexibility"; Rec."Planning Flexibility")
{
ApplicationArea = Planning;
Visible = false;
}
field("Whse. Outstanding Qty. (Base)"; Rec."Whse. Outstanding Qty. (Base)")
{
ApplicationArea = Warehouse;
ToolTip = 'Specifies how many units on the purchase order line remain to be handled in warehouse documents.';
Visible = false;
}
field("Inbound Whse. Handling Time"; Rec."Inbound Whse. Handling Time")
{
ApplicationArea = Warehouse;
Visible = false;
}
field("Blanket Order No."; Rec."Blanket Order No.")
{
ApplicationArea = Suite;
Visible = false;
}
field("Blanket Order Line No."; Rec."Blanket Order Line No.")
{
ApplicationArea = Suite;
Visible = false;
}
field("Appl.-to Item Entry"; Rec."Appl.-to Item Entry")
{
ApplicationArea = Suite;
Visible = false;
}
field("Deferral Code"; Rec."Deferral Code")
{
ApplicationArea = Suite;
Enabled = (Rec.Type <> Rec.Type::"Fixed Asset") and (Rec.Type <> Rec.Type::" ");
TableRelation = "Deferral Template"."Deferral Code";
Visible = false;
trigger OnAssistEdit()
begin
CurrPage.SaveRecord();
Commit();
Rec.ShowDeferralSchedule();
end;
}
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(ShortcutDimCode3; 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]);
OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 3);
end;
}
field(ShortcutDimCode4; 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]);
OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 4);
end;
}
field(ShortcutDimCode5; 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]);
OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 5);
end;
}
field(ShortcutDimCode6; 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]);
OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 6);
end;
}
field(ShortcutDimCode7; 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]);
OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 7);
end;
}
field(ShortcutDimCode8; 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]);
OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 8);
end;
}
field("Document No."; Rec."Document No.")
{
ApplicationArea = Suite;
Editable = false;
Visible = false;
}
field("Line No."; Rec."Line No.")
{
ApplicationArea = Suite;
Editable = false;
ToolTip = 'Specifies the number of this line.';
Visible = false;
}
field("Over-Receipt Quantity"; Rec."Over-Receipt Quantity")
{
ApplicationArea = All;
Visible = OverReceiptAllowed;
trigger OnValidate()
begin
CurrPage.Update(true);
end;
}
field("Over-Receipt Code"; Rec."Over-Receipt Code")
{
ApplicationArea = All;
Visible = OverReceiptAllowed;
}
field("Gross Weight"; Rec."Gross Weight")
{
Caption = 'Unit Gross Weight';
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Net Weight"; Rec."Net Weight")
{
Caption = 'Unit Net Weight';
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Unit Volume"; Rec."Unit Volume")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Units per Parcel"; Rec."Units per Parcel")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("FA Posting Date"; Rec."FA Posting Date")
{
ApplicationArea = FixedAssets;
Visible = false;
}
field("No. of Fixed Asset Cards"; Rec."No. of Fixed Asset Cards")
{
ApplicationArea = FixedAssets;
Visible = false;
}
field("Attached to Line No."; Rec."Attached to Line No.")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Attached Lines Count"; Rec."Attached Lines Count")
{
ApplicationArea = Basic, Suite;
Visible = AttachingLinesEnabled;
}
field("Spend Request No."; Rec."Spend Request No.")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
}
group(Control43)
{
ShowCaption = false;
group(Control37)
{
ShowCaption = false;
field(AmountBeforeDiscount; TotalPurchaseLine."Line Amount")
{
ApplicationArea = Suite;
AutoFormatExpression = Currency.Code;
AutoFormatType = 1;
CaptionClass = DocumentTotals.GetTotalLineAmountWithVATAndCurrencyCaption(Currency.Code, TotalPurchaseHeader."Prices Including VAT");
Caption = 'Subtotal Excl. VAT';
Editable = false;
ToolTip = 'Specifies the sum of the value in the Line Amount Excl. VAT field on all lines in the document.';
trigger OnValidate()
begin
DocumentTotals.PurchaseDocTotalsNotUpToDate();
end;
}
field("Invoice Discount Amount"; InvoiceDiscountAmount)
{
ApplicationArea = Suite;
AutoFormatExpression = Currency.Code;
AutoFormatType = 1;
CaptionClass = DocumentTotals.GetInvoiceDiscAmountWithVATAndCurrencyCaption(Rec.FieldCaption("Inv. Discount Amount"), Currency.Code);
Caption = 'Invoice Discount Amount';
Editable = InvDiscAmountEditable;
ToolTip = 'Specifies a discount amount that is deducted from the value of the Total Incl. VAT field, based on purchase lines where the Allow Invoice Disc. field is selected. You can enter or change the amount manually.';
trigger OnValidate()
begin
ValidateInvoiceDiscountAmount();
DocumentTotals.PurchaseDocTotalsNotUpToDate();
end;
}
field("Invoice Disc. Pct."; InvoiceDiscountPct)
{
ApplicationArea = Suite;
AutoFormatType = 0;
Caption = 'Invoice Discount %';
DecimalPlaces = 0 : 3;
Editable = InvDiscAmountEditable;
ToolTip = 'Specifies a discount percentage that is applied to the invoice, based on purchase lines where the Allow Invoice Disc. field is selected. The percentage and criteria are defined in the Vendor Invoice Discounts page, but you can enter or change the percentage manually.';
trigger OnValidate()
begin
AmountWithDiscountAllowed := DocumentTotals.CalcTotalPurchAmountOnlyDiscountAllowed(Rec);
InvoiceDiscountAmount := Round(AmountWithDiscountAllowed * InvoiceDiscountPct / 100, Currency."Amount Rounding Precision");
ValidateInvoiceDiscountAmount();
DocumentTotals.PurchaseDocTotalsNotUpToDate();
end;
}
}
group(Control19)
{
ShowCaption = false;
field("Total Amount Excl. VAT"; TotalPurchaseLine.Amount)
{
ApplicationArea = Suite;
AutoFormatExpression = Currency.Code;
AutoFormatType = 1;
CaptionClass = DocumentTotals.GetTotalExclVATCaption(Currency.Code);
Caption = 'Total Amount Excl. VAT';
DrillDown = false;
Editable = false;
ToolTip = 'Specifies the sum of the value in the Line Amount Excl. VAT field on all lines in the document minus any discount amount in the Invoice Discount Amount field.';
}
field("Total VAT Amount"; VATAmount)
{
ApplicationArea = Suite;
AutoFormatExpression = Currency.Code;
AutoFormatType = 1;
CaptionClass = DocumentTotals.GetTotalVATCaption(Currency.Code);
Caption = 'Total VAT';
Editable = false;
ToolTip = 'Specifies the sum of VAT amounts on all lines in the document.';
}
field("Total Amount Incl. VAT"; TotalPurchaseLine."Amount Including VAT")
{
ApplicationArea = Suite;
AutoFormatExpression = Currency.Code;
AutoFormatType = 1;
CaptionClass = DocumentTotals.GetTotalInclVATCaption(Currency.Code);
Caption = 'Total Amount Incl. VAT';
Editable = false;
ToolTip = 'Specifies the sum of the value in the Line Amount Incl. VAT field on all lines in the document minus any discount amount in the Invoice Discount Amount field.';
}
}
}
}
}
actions
{
area(processing)
{
action(SelectMultiItems)
{
AccessByPermission = TableData Item = R;
ApplicationArea = Basic, Suite;
Caption = 'Select items';
Ellipsis = true;
Image = NewItem;
ToolTip = 'Add two or more items from the full list of your inventory items.';
trigger OnAction()
begin
Rec.SelectMultipleItems();
end;
}
group("&Line")
{
Caption = '&Line';
Image = Line;
group("Item Availability by")
{
Caption = 'Item Availability by';
Image = ItemAvailability;
Enabled = Rec.Type = Rec.Type::Item;
action("Event")
{
ApplicationArea = Basic, Suite;
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
PurchAvailabilityMgt.ShowItemAvailabilityFromPurchLine(Rec, "Item Availability Type"::"Event");
end;
}
action(Period)
{
ApplicationArea = Basic, Suite;
Caption = 'Period';
Image = Period;
ToolTip = 'Show the projected quantity of the item over time according to time periods, such as day, week, or month.';
trigger OnAction()
begin
PurchAvailabilityMgt.ShowItemAvailabilityFromPurchLine(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
PurchAvailabilityMgt.ShowItemAvailabilityFromPurchLine(Rec, "Item Availability Type"::Variant);
end;
}
action(Location)
{
AccessByPermission = TableData Location = R;
ApplicationArea = Location;
Caption = 'Location';
Image = Warehouse;
ToolTip = 'View the actual and projected quantity of the item per location.';
trigger OnAction()
begin
PurchAvailabilityMgt.ShowItemAvailabilityFromPurchLine(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")
{
AccessByPermission = TableData "BOM Buffer" = R;
ApplicationArea = Assembly;
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
PurchAvailabilityMgt.ShowItemAvailabilityFromPurchLine(Rec, "Item Availability Type"::BOM);
end;
}
}
action("Reservation Entries")
{
AccessByPermission = TableData Item = R;
ApplicationArea = Reservation;
Caption = 'Reservation Entries';
Image = ReservationLedger;
Enabled = Rec.Type = Rec.Type::Item;
ToolTip = 'View all reservation entries for the selected item. This action is available only for lines that contain an item.';
trigger OnAction()
begin
Rec.ShowReservationEntries(true);
end;
}
action("Item Tracking Lines")
{
ApplicationArea = ItemTracking;
Caption = 'Item &Tracking Lines';
Image = ItemTrackingLines;
ShortCutKey = 'Ctrl+Alt+I';
Enabled = Rec.Type = Rec.Type::Item;
ToolTip = 'View or edit serial, lot and package numbers for the selected item. This action is available only for lines that contain an item.';
trigger OnAction()
begin
Rec.OpenItemTrackingLines();
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("Co&mments")
{
ApplicationArea = Comments;
Caption = 'Co&mments';
Image = ViewComments;
ToolTip = 'View or add comments for the record.';
trigger OnAction()
begin
Rec.ShowLineComments();
end;
}
action(ItemChargeAssignment)
{
AccessByPermission = TableData "Item Charge" = R;
ApplicationArea = ItemCharges;
Caption = 'Item Charge &Assignment';
Image = ItemCosts;
Enabled = Rec.Type = Rec.Type::"Charge (Item)";
ToolTip = 'Record additional direct costs, for example for freight. This action is available only for Charge (Item) line types.';
trigger OnAction()
begin
Rec.ShowItemChargeAssgnt();
SetItemChargeFieldsStyle();
end;
}
action(DocumentLineTracking)
{
ApplicationArea = Basic, Suite;
Caption = 'Document &Line Tracking';
ToolTip = 'View related open, posted, or archived documents or document lines.';
trigger OnAction()
begin
ShowDocumentLineTracking();
end;
}
action(DeferralSchedule)
{
ApplicationArea = Suite;
Caption = 'Deferral Schedule';
Enabled = Rec."Deferral Code" <> '';
Image = PaymentPeriod;
ToolTip = 'View or edit the deferral schedule that governs how revenue made with this purchase document is deferred to different accounting periods when the document is posted.';
trigger OnAction()
begin
Rec.ShowDeferralSchedule();
end;
}
action(RedistributeAccAllocations)
{
ApplicationArea = All;
Caption = 'Redistribute Account Allocations';
Image = EditList;
#pragma warning disable AA0219
ToolTip = 'Use this action to redistribute the account allocations for this line.';
#pragma warning restore AA0219
trigger OnAction()
var
AllocAccManualOverride: Page "Redistribute Acc. Allocations";
begin
if ((Rec."Type" <> Rec."Type"::"Allocation Account") and (Rec."Selected Alloc. Account No." = '')) then
Error(ActionOnlyAllowedForAllocationAccountsErr);
AllocAccManualOverride.SetParentSystemId(Rec.SystemId);
AllocAccManualOverride.SetParentTableId(Database::"Purchase Line");
AllocAccManualOverride.RunModal();
end;
}
action(ReplaceAllocationAccountWithLines)
{
ApplicationArea = All;
Caption = 'Generate lines from Allocation Account Line';
Image = CreateLinesFromJob;
#pragma warning disable AA0219
ToolTip = 'Use this action to replace the Allocation Account line with the actual lines that would be generated from the line itself.';
#pragma warning restore AA0219
trigger OnAction()
var
PurchaseAllocAccMgt: Codeunit "Purchase Alloc. Acc. Mgt.";
begin
if ((Rec."Type" <> Rec."Type"::"Allocation Account") and (Rec."Selected Alloc. Account No." = '')) then
Error(ActionOnlyAllowedForAllocationAccountsErr);
PurchaseAllocAccMgt.CreateLinesFromAllocationAccountLine(Rec);
Rec.Delete();
CurrPage.Update(false);
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;
}
action(MatchedInvoiceLines)
{
ApplicationArea = Suite;
Caption = 'Matched Invoice Lines';
Image = TransferToLines;
ToolTip = 'View the invoice lines matched to this order line.';
trigger OnAction()
var
MatchedOrderLineMgmt: Codeunit "Matched Order Line Mgmt.";
begin
MatchedOrderLineMgmt.ShowMatchedInvoiceLines(Rec);
end;
}
}
group("F&unctions")
{
Caption = 'F&unctions';
Image = "Action";
action("E&xplode BOM")
{
AccessByPermission = TableData "BOM Component" = R;
ApplicationArea = Suite;
Caption = 'E&xplode BOM';
Image = ExplodeBOM;
Enabled = Rec.Type = Rec.Type::Item;
ToolTip = 'Add a line for each component on the bill of materials for the selected item. For example, this is useful for selling the parent item as a kit. CAUTION: The line for the parent item will be deleted and only its description will display. To undo this action, delete the component lines and add a line for the parent item again. This action is available only for lines that contain an item.';
trigger OnAction()
begin
ExplodeBOM();
end;
}
action("Insert Ext. Texts")
{
AccessByPermission = TableData "Extended Text Header" = R;
ApplicationArea = Suite;
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;
}
action("Attach to Inventory Item Line")
{
ApplicationArea = Basic, Suite;
Caption = 'Attach to inventory item line';
Image = Allocations;
Visible = AttachingLinesEnabled;
Enabled = AttachToInvtItemEnabled;
ToolTip = 'Attach the selected non-inventory product lines to a inventory item line in this purchase order.';
trigger OnAction()
var
SelectedPurchLine: Record "Purchase Line";
begin
CurrPage.SetSelectionFilter(SelectedPurchLine);
Rec.AttachToInventoryItemLine(SelectedPurchLine);
end;
}
action(Reserve)
{
ApplicationArea = Reservation;
Caption = '&Reserve';
Ellipsis = true;
Image = Reserve;
Enabled = Rec.Type = Rec.Type::Item;
ToolTip = 'Reserve the quantity of the selected item that is required on the document line from which you opened this page. This action is available only for lines that contain an item.';
trigger OnAction()
begin
Rec.Find();
Rec.ShowReservation();
end;
}
action(OrderTracking)
{
ApplicationArea = Suite;
Caption = 'Order &Tracking';
Image = OrderTracking;
Enabled = Rec.Type = Rec.Type::Item;
ToolTip = 'Track the connection of a supply to its corresponding demand for the selected item. This can help you find the original demand that created a specific production order or purchase order. This action is available only for lines that contain an item.';
trigger OnAction()
begin
Rec.ShowOrderTracking();
end;
}
}
group("O&rder")
{
Caption = 'O&rder';
Image = "Order";
group("Dr&op Shipment")
{
Caption = 'Dr&op Shipment';
Image = Delivery;
action("Sales &Order")
{
AccessByPermission = TableData "Sales Shipment Header" = R;
ApplicationArea = Suite;
Caption = 'Sales &Order';
Image = Document;
ToolTip = 'View the sales order that is the source of the line. This applies only to drop shipments and special orders.';
trigger OnAction()
begin
OpenSalesOrderForm();
end;
}
}
group("Speci&al Order")
{
Caption = 'Speci&al Order';
Image = SpecialOrder;
action(Action1901038504)
{
AccessByPermission = TableData "Sales Shipment Header" = R;
ApplicationArea = Suite;
Caption = 'Sales &Order';
Image = Document;
ToolTip = 'View the sales order that is the source of the line. This applies only to drop shipments and special orders.';
trigger OnAction()
begin
OpenSpecOrderSalesOrderForm();
end;
}
}
action(BlanketOrder)
{
ApplicationArea = Suite;
Caption = 'Blanket Order';
Image = BlanketOrder;
ToolTip = 'View the blanket purchase order.';
trigger OnAction()
var
PurchaseHeader: Record "Purchase Header";
BlanketPurchaseOrder: Page "Blanket Purchase Order";
begin
Rec.TestField("Blanket Order No.");
PurchaseHeader.SetRange("No.", Rec."Blanket Order No.");
if not PurchaseHeader.IsEmpty() then begin
BlanketPurchaseOrder.SetTableView(PurchaseHeader);
BlanketPurchaseOrder.Editable := false;
BlanketPurchaseOrder.Run();
end;
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 purchase 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 purchase lines, including lines with and without issues.';
trigger OnAction()
begin
Rec.SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);
end;
}
}
group("Page")
{
Caption = 'Page';
action(EditInExcel)
{
ApplicationArea = Basic, Suite;
Caption = 'Edit in Excel';
Image = Excel;
Visible = IsSaaSExcelAddinEnabled;
ToolTip = 'Send the data in the sub page to an Excel file for analysis or editing';
AccessByPermission = System "Allow Action Export To Excel" = X;
trigger OnAction()
var
EditinExcel: Codeunit "Edit in Excel";
EditinExcelFilters: Codeunit "Edit in Excel Filters";
begin
EditinExcelFilters.AddFieldV2('Document_No', Enum::"Edit in Excel Filter Type"::Equal, Rec."Document No.", Enum::"Edit in Excel Edm Type"::"Edm.String");
EditinExcel.EditPageInExcel(
'Purchase_Order_Line',
Page::"Purchase Order Subform",
EditinExcelFilters,
StrSubstNo(ExcelFileNameTxt, Rec."Document No."));
end;
}
}
}
}
trigger OnAfterGetCurrRecord()
begin
GetTotalsPurchaseHeader();
CalculateTotals();
UpdateEditableOnRow();
UpdateTypeText();
SetItemChargeFieldsStyle();
end;
trigger OnAfterGetRecord()
var
Item: Record "Item";
begin
Rec.ShowShortcutDimCode(ShortcutDimCode);
UpdateTypeText();
SetItemChargeFieldsStyle();
if Rec."Variant Code" = '' then
VariantCodeMandatory := Item.IsVariantMandatory(Rec.Type = Rec.Type::Item, Rec."No.");
end;
trigger OnDeleteRecord(): Boolean
var
PurchLineReserve: Codeunit "Purch. Line-Reserve";
IsHandled: Boolean;
Result: Boolean;
begin
IsHandled := false;
OnBeforeOnDeleteRecord(Rec, Result, IsHandled);
if IsHandled then
exit(Result);
if (Rec.Quantity <> 0) and Rec.ItemExists(Rec."No.") then begin
Commit();
if not PurchLineReserve.DeleteLineConfirm(Rec) then
exit(false);
OnBeforeDeleteReservationEntries(Rec);
PurchLineReserve.DeleteLine(Rec);
end;
DocumentTotals.PurchaseDocTotalsNotUpToDate();
end;
trigger OnFindRecord(Which: Text): Boolean
begin
DocumentTotals.PurchaseCheckAndClearTotals(Rec, xRec, TotalPurchaseLine, VATAmount, InvoiceDiscountAmount, InvoiceDiscountPct);
exit(Rec.Find(Which));
end;
trigger OnInit()
var
ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade";
begin
PurchasesPayablesSetup.Get();
InventorySetup.Get();
TempOptionLookupBuffer.FillLookupBuffer(TempOptionLookupBuffer."Lookup Type"::Purchases);
IsFoundation := ApplicationAreaMgmtFacade.IsFoundationEnabled();
Currency.InitRoundingPrecision();
end;
trigger OnModifyRecord(): Boolean
begin
DocumentTotals.PurchaseCheckIfDocumentChanged(Rec, xRec);
end;
trigger OnNewRecord(BelowxRec: Boolean)
begin
Rec.InitType();
SetDefaultType();
Clear(ShortcutDimCode);
UpdateTypeText();
end;
trigger OnOpenPage()
var
AllocationAccountMgt: Codeunit "Allocation Account Mgt.";
begin
UseAllocationAccountNumber := AllocationAccountMgt.UseAllocationAccountNoField();
SetOpenPage();
SetDimensionsVisibility();
SetOverReceiptControlsVisibility();
SetItemReferenceVisibility();
end;
var
PurchaseHeader: Record "Purchase Header";
PurchasesPayablesSetup: Record "Purchases & Payables Setup";
InventorySetup: Record "Inventory Setup";
TempOptionLookupBuffer: Record "Option Lookup Buffer" temporary;
TransferExtendedText: Codeunit "Transfer Extended Text";
PurchAvailabilityMgt: Codeunit "Purch. Availability Mgt.";
#pragma warning disable AA0074
Text001: Label 'You cannot use the Explode BOM function because a prepayment of the purchase order has been invoiced.';
#pragma warning restore AA0074
PurchCalcDiscByType: Codeunit "Purch - Calc Disc. By Type";
DocumentTotals: Codeunit "Document Totals";
AmountWithDiscountAllowed: Decimal;
TypeAsText: Text[30];
ItemChargeStyleExpression: Text;
ItemChargeToHandleStyleExpression: Text;
VariantCodeMandatory: Boolean;
BackgroundErrorCheck: Boolean;
ShowAllLinesEnabled: Boolean;
IsFoundation: Boolean;
IsSaaSExcelAddinEnabled: Boolean;
AttachingLinesEnabled: Boolean;
ShowNonDedVATInLines: Boolean;
UpdateInvDiscountQst: Label 'One or more lines have been invoiced. The discount distributed to invoiced lines will not be taken into account.\\Do you want to update the invoice discount?';
CurrPageIsEditable: Boolean;
SuppressTotals: Boolean;
UseAllocationAccountNumber: Boolean;
ActionOnlyAllowedForAllocationAccountsErr: Label 'This action is only available for lines that have Allocation Account set as Type.';
ExcelFileNameTxt: Label 'Purchase Order %1 - Lines', Comment = '%1 = document number, ex. 10000';
protected var
Currency: Record Currency;
TotalPurchaseHeader: Record "Purchase Header";
TotalPurchaseLine: Record "Purchase Line";
ShortcutDimCode: array[8] of Code[20];
InvoiceDiscountAmount: Decimal;
InvoiceDiscountPct: Decimal;
VATAmount: Decimal;
DimVisible1: Boolean;
DimVisible2: Boolean;
DimVisible3: Boolean;
DimVisible4: Boolean;
DimVisible5: Boolean;
DimVisible6: Boolean;
DimVisible7: Boolean;
DimVisible8: Boolean;
IsBlankNumber: Boolean;
IsCommentLine: Boolean;
OverReceiptAllowed: Boolean;
ItemReferenceVisible: Boolean;
AttachToInvtItemEnabled: Boolean;
InvDiscAmountEditable: Boolean;
local procedure SetOpenPage()
var
ServerSetting: Codeunit "Server Setting";
DocumentErrorsMgt: Codeunit "Document Errors Mgt.";
NonDeductibleVAT: Codeunit "Non-Deductible VAT";
begin
OnBeforeSetOpenPage();
IsSaaSExcelAddinEnabled := ServerSetting.GetIsSaasExcelAddinEnabled();
SuppressTotals := CurrentClientType() = ClientType::ODataV4;
BackgroundErrorCheck := DocumentErrorsMgt.BackgroundValidationEnabled();
AttachingLinesEnabled :=
PurchasesPayablesSetup."Auto Post Non-Invt. via Whse." = PurchasesPayablesSetup."Auto Post Non-Invt. via Whse."::"Attached/Assigned";
ShowNonDedVATInLines := NonDeductibleVAT.ShowNonDeductibleVATInLines();
end;
procedure ApproveCalcInvDisc()
begin
CODEUNIT.Run(CODEUNIT::"Purch.-Disc. (Yes/No)", Rec);
DocumentTotals.PurchaseDocTotalsNotUpToDate();
end;
local procedure ValidateInvoiceDiscountAmount()
var
ConfirmManagement: Codeunit "Confirm Management";
begin
if SuppressTotals then
exit;
PurchaseHeader.Get(Rec."Document Type", Rec."Document No.");
if PurchaseHeader.InvoicedLineExists() then
if not ConfirmManagement.GetResponseOrDefault(UpdateInvDiscountQst, true) then
exit;
DocumentTotals.PurchaseDocTotalsNotUpToDate();
PurchCalcDiscByType.ApplyInvDiscBasedOnAmt(InvoiceDiscountAmount, PurchaseHeader);
CurrPage.Update(false);
end;
local procedure ExplodeBOM()
begin
if Rec."Prepmt. Amt. Inv." <> 0 then
Error(Text001);
CODEUNIT.Run(CODEUNIT::"Purch.-Explode BOM", Rec);
DocumentTotals.PurchaseDocTotalsNotUpToDate();
end;
local procedure OpenSalesOrderForm()
var
SalesHeader: Record "Sales Header";
SalesOrder: Page "Sales Order";
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeOpenSalesOrderForm(Rec, SalesHeader, SalesOrder, IsHandled);
if IsHandled then
exit;
Rec.TestField("Sales Order No.");
SalesHeader.SetRange("No.", Rec."Sales Order No.");
SalesOrder.SetTableView(SalesHeader);
SalesOrder.Editable := false;
SalesOrder.Run();
end;
procedure InsertExtendedText(Unconditionally: Boolean)
var
IsHandled: Boolean;
begin
if not Unconditionally and (Rec."No." = xRec."No.") then
exit;
IsHandled := false;
OnBeforeInsertExtendedText(Rec, IsHandled);
if IsHandled then
exit;
if TransferExtendedText.PurchCheckIfAnyExtText(Rec, Unconditionally) then begin
CurrPage.SaveRecord();
TransferExtendedText.InsertPurchExtText(Rec);
end;
if TransferExtendedText.MakeUpdate() then
UpdateForm(true);
end;
procedure ShowTracking()
begin
Rec.ShowOrderTracking();
end;
protected procedure OpenSpecOrderSalesOrderForm()
var
SalesHeader: Record "Sales Header";
SalesOrder: Page "Sales Order";
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeOpenSpecOrderSalesOrderForm(Rec, SalesHeader, SalesOrder, IsHandled);
if IsHandled then
exit;
Rec.TestField("Special Order Sales No.");
SalesHeader.SetRange("No.", Rec."Special Order Sales No.");
SalesOrder.SetTableView(SalesHeader);
SalesOrder.Editable := false;
SalesOrder.Run();
end;
procedure UpdateForm(SetSaveRecord: Boolean)
begin
CurrPage.Update(SetSaveRecord);
end;
procedure NoOnAfterValidate()
begin
UpdateEditableOnRow();
InsertExtendedText(false);
if (Rec.Type = Rec.Type::"Charge (Item)") and (Rec."No." <> xRec."No.") and
(xRec."No." <> '')
then
CurrPage.SaveRecord();
OnAfterNoOnAfterValidate(Rec, xRec);
end;
procedure ShowDocumentLineTracking()
var
DocumentLineTrackingPage: Page "Document Line Tracking";
begin
Clear(DocumentLineTrackingPage);
DocumentLineTrackingPage.SetSourceDoc(
"Document Line Source Type"::"Purchase Order", Rec."Document No.", Rec."Line No.", Rec."Blanket Order No.", Rec."Blanket Order Line No.", '', 0);
DocumentLineTrackingPage.RunModal();
end;
procedure RedistributeTotalsOnAfterValidate()
begin
if SuppressTotals then
exit;
CurrPage.SaveRecord();
DocumentTotals.PurchaseRedistributeInvoiceDiscountAmounts(Rec, VATAmount, TotalPurchaseLine);
CurrPage.Update(false);
end;
local procedure GetTotalsPurchaseHeader()
begin
DocumentTotals.GetTotalPurchaseHeaderAndCurrency(Rec, TotalPurchaseHeader, Currency);
end;
procedure ClearTotalPurchaseHeader();
begin
Clear(TotalPurchaseHeader);
end;
procedure CalculateTotals()
var
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeCalculateTotals(Rec, SuppressTotals, DocumentTotals, IsHandled);
if IsHandled then
exit;
if SuppressTotals then
exit;
DocumentTotals.PurchaseCheckIfDocumentChanged(Rec, xRec);
DocumentTotals.CalculatePurchaseSubPageTotals(
TotalPurchaseHeader, TotalPurchaseLine, VATAmount, InvoiceDiscountAmount, InvoiceDiscountPct);
DocumentTotals.RefreshPurchaseLine(Rec);
end;
procedure DeltaUpdateTotals()
begin
if SuppressTotals then
exit;
OnBeforeDeltaUpdateTotals(Rec, xRec);
DocumentTotals.PurchaseDeltaUpdateTotals(Rec, xRec, TotalPurchaseLine, VATAmount, InvoiceDiscountAmount, InvoiceDiscountPct);
CheckSendLineInvoiceDiscountResetNotification();
end;
procedure ForceTotalsCalculation()
begin
DocumentTotals.PurchaseDocTotalsNotUpToDate();
end;
local procedure CheckSendLineInvoiceDiscountResetNotification()
var
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeCheckSendLineInvoiceDiscountResetNotification(Rec, IsHandled);
if IsHandled then
exit;
if Rec."Line Amount" <> xRec."Line Amount" then
Rec.SendLineInvoiceDiscountResetNotification();
end;
procedure UpdateEditableOnRow()
begin
IsCommentLine := Rec.Type = Rec.Type::" ";
IsBlankNumber := IsCommentLine;
if AttachingLinesEnabled then
AttachToInvtItemEnabled := not Rec.IsInventoriableItem();
CurrPageIsEditable := CurrPage.Editable;
InvDiscAmountEditable :=
CurrPageIsEditable and not PurchasesPayablesSetup."Calc. Inv. Discount" and
(TotalPurchaseHeader.Status = TotalPurchaseHeader.Status::Open);
OnAfterUpdateEditableOnRow(Rec, IsCommentLine, IsBlankNumber);
end;
procedure UpdateTypeText()
var
RecRef: RecordRef;
begin
if not IsFoundation then
exit;
OnBeforeUpdateTypeText(Rec);
RecRef.GetTable(Rec);
TypeAsText := TempOptionLookupBuffer.FormatOption(RecRef.Field(Rec.FieldNo(Type)));
end;
local procedure SetItemChargeFieldsStyle()
begin
ItemChargeStyleExpression := '';
ItemChargeToHandleStyleExpression := '';
if Rec.AssignedItemCharge() then begin
if Rec."Qty. To Assign" <> (Rec.Quantity - Rec."Qty. Assigned") then
ItemChargeStyleExpression := 'Unfavorable';
if Rec."Item Charge Qty. to Handle" <> Rec."Qty. to Invoice" then
ItemChargeToHandleStyleExpression := 'Unfavorable';
end;
end;
local procedure SetItemReferenceVisibility()
var
ItemReference: Record "Item Reference";
begin
ItemReferenceVisible := not ItemReference.IsEmpty();
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);
OnAfterSetDimensionsVisibility();
end;
local procedure SetDefaultType()
var
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeSetDefaultType(Rec, xRec, IsHandled);
if IsHandled then
exit;
if xRec."Document No." = '' then
Rec.Type := Rec.GetDefaultLineType();
end;
local procedure SetOverReceiptControlsVisibility()
var
OverReceiptMgt: Codeunit "Over-Receipt Mgt.";
begin
OverReceiptAllowed := OverReceiptMgt.IsOverReceiptAllowed();
end;
[IntegrationEvent(true, false)]
local procedure OnAfterNoOnAfterValidate(var PurchaseLine: Record "Purchase Line"; var xPurchaseLine: Record "Purchase Line")
begin
end;
[IntegrationEvent(false, false)]
local procedure OnAfterUpdateEditableOnRow(PurchaseLine: Record "Purchase Line"; var IsCommentLine: Boolean; var IsBlankNumber: Boolean);
begin
end;
[IntegrationEvent(false, false)]
local procedure OnAfterValidateShortcutDimCode(var PurchaseLine: Record "Purchase Line"; var ShortcutDimCode: array[8] of Code[20]; DimIndex: Integer)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeCalculateTotals(var PurchLine: Record "Purchase Line"; SuppressTotals: Boolean; var DocumentTotals: Codeunit "Document Totals"; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeCheckSendLineInvoiceDiscountResetNotification(var PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeInsertExtendedText(var PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeOpenSpecOrderSalesOrderForm(var PurchaseLine: Record "Purchase Line"; var SalesHeader: Record "Sales Header"; var SalesOrder: Page "Sales Order"; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeSetDefaultType(var PurchaseLine: Record "Purchase Line"; var xPurchaseLine: Record "Purchase Line"; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeUpdateTypeText(var PurchaseLine: Record "Purchase Line")
begin
end;
[IntegrationEvent(false, false)]
local procedure OnItemReferenceNoOnLookup(var PurchaseLine: Record "Purchase Line")
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeOpenSalesOrderForm(var PurchaseLine: Record "Purchase Line"; var SalesHeader: Record "Sales Header"; var SalesOrder: Page "Sales Order"; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(true, false)]
local procedure OnBeforeSetOpenPage()
begin
end;
[IntegrationEvent(true, false)]
local procedure OnAfterSetDimensionsVisibility()
begin
end;
[IntegrationEvent(true, false)]
local procedure OnBeforeDeltaUpdateTotals(var PurchaseLine: Record "Purchase Line"; xPurchaseLine: Record "Purchase Line")
begin
end;
[IntegrationEvent(true, false)]
local procedure OnBeforeDeleteReservationEntries(var PurchaseLine: Record "Purchase Line");
begin
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeOnDeleteRecord(var PurchaseLine: Record "Purchase Line"; var Result: Boolean; var IsHandled: Boolean)
begin
end;
}