Table extension 20510 Subc. RequisitionLine

Subcontracting, Microsoft.Manufacturing.Subcontracting

src/Apps/W1/Subcontracting/App/src/Purchase/SubcRequisitionLine.TableExt.al192 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.Manufacturing.Subcontracting;using Microsoft.Finance.Currency;using Microsoft.Finance.GeneralLedger.Setup;using Microsoft.Foundation.UOM;using Microsoft.Inventory.Item;using Microsoft.Inventory.Requisition;using Microsoft.Manufacturing.Routing;tableextension 20510 "Subc. RequisitionLine" extends "Requisition Line"{    AllowInCustomizations = AsReadOnly;    fields    {        field(20516; "Subc. Standard Task Code"; Code[10])        {            Caption = 'Standard Task Code';            DataClassification = CustomerContent;            TableRelation = "Standard Task";            ToolTip = 'Specifies the code that is assigned to the standard task.';            trigger OnValidate()            begin#if not CLEAN29#pragma warning disable AL0432                if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432                    exit;#endif                if (Type = Type::Item) and                   ("No." <> '') and                   ("Prod. Order No." <> '') and                   (xRec."Subc. Standard Task Code" <> "Subc. Standard Task Code")                then                    UpdateSubcontractorPrice();            end;        }        field(20517; "Base UM Qty/PL UM Qty"; Decimal)        {            Access = Internal;            AutoFormatType = 0;            Caption = 'Base UM Qty/Price list UM Qty';            DataClassification = CustomerContent;            DecimalPlaces = 0 : 5;            Editable = false;            InitValue = 1;            ToolTip = 'Specifies the quantity of the base unit of measure or the price list unit of measure.';        }        field(20518; "PL UM Qty/Base UM Qty"; Decimal)        {            Access = Internal;            AutoFormatType = 0;            Caption = 'Price list UM Qty/Base UM Qty';            DataClassification = CustomerContent;            DecimalPlaces = 0 : 5;            ToolTip = 'Specifies the quantity of the price list unit of measure or the base unit of measure.';            trigger OnValidate()            begin#if not CLEAN29#pragma warning disable AL0432                if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432                    exit;#endif                if (CurrFieldNo = FieldNo("PL UM Qty/Base UM Qty")) and                   ("Prod. Order No." <> '') and                   (Type = Type::Item) and                   ("PL UM Qty/Base UM Qty" <> xRec."PL UM Qty/Base UM Qty")                then begin                    "Base UM Qty/PL UM Qty" := GetQuantityBase() / "PL UM Qty/Base UM Qty";                    Validate("Subc. Pricelist Cost");                end;            end;        }        field(20519; "Subc. UoM for Pricelist"; Code[10])        {            Access = Public;            Caption = 'UoM for Price list';            DataClassification = CustomerContent;            TableRelation = "Unit of Measure";            ToolTip = 'Specifies the unit of measure for the price list that is on the subcontracting worksheet.';            trigger OnValidate()            begin#if not CLEAN29#pragma warning disable AL0432                if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432                    exit;#endif                if (CurrFieldNo = FieldNo("Subc. UoM for Pricelist")) and                   ("Prod. Order No." <> '') and                   (Type = Type::Item)                then                    UpdateSubcontractorPriceUOM();            end;        }        field(20520; "Subc. Pricelist Cost"; Decimal)        {            Access = Internal;            AutoFormatExpression = "Currency Code";            AutoFormatType = 2;            Caption = 'Price list Cost';            DataClassification = CustomerContent;            ToolTip = 'Specifies the price list cost for the item on the subcontracting worksheet.';            trigger OnValidate()            var                Currency: Record Currency;                GeneralLedgerSetup: Record "General Ledger Setup";            begin                if ("Prod. Order No." <> '') and                   (Type = Type::Item)                then begin                    "Direct Unit Cost" := "Subc. Pricelist Cost" / "Base UM Qty/PL UM Qty" * GetQuantityForUOM();                    if ("Currency Code" <> '') and ("Direct Unit Cost" <> 0) then begin                        Currency.Initialize("Currency Code");                        Currency.TestField("Unit-Amount Rounding Precision");                        "Direct Unit Cost" := Round("Direct Unit Cost", Currency."Unit-Amount Rounding Precision");                    end else begin                        GeneralLedgerSetup.Get();                        "Direct Unit Cost" := Round("Direct Unit Cost", GeneralLedgerSetup."Unit-Amount Rounding Precision");                    end;                end;            end;        }    }#if not CLEAN29    var#pragma warning disable AL0432        SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler";#pragma warning restore AL0432#endif    procedure GetQuantityForUOM(): Decimal    var        ItemUnitofMeasure: Record "Item Unit of Measure";    begin#if not CLEAN29#pragma warning disable AL0432        if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432            exit(0);#endif        ItemUnitofMeasure.Get("No.", "Unit of Measure Code");        exit(ItemUnitofMeasure."Qty. per Unit of Measure");    end;    procedure GetQuantityBase(): Decimal    var        ItemUnitofMeasure: Record "Item Unit of Measure";    begin#if not CLEAN29#pragma warning disable AL0432        if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432            exit(0);#endif        ItemUnitofMeasure.Get("No.", "Unit of Measure Code");        exit(Round(Quantity * ItemUnitofMeasure."Qty. per Unit of Measure", 0.00001));    end;    procedure UpdateSubcontractorPrice()    var        SubcPriceManagement: Codeunit "Subc. Price Management";    begin#if not CLEAN29#pragma warning disable AL0432        if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432            exit;#endif        if (Type = Type::Item) and ("No." <> '') and ("Prod. Order No." <> '') then            SubcPriceManagement.GetSubcPriceForReqLine(Rec, '');    end;    procedure UpdateSubcontractorPriceUOM()    var        SubcPriceManagement: Codeunit "Subc. Price Management";    begin#if not CLEAN29#pragma warning disable AL0432        if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432            exit;#endif        if (Type = Type::Item) and ("No." <> '') and ("Prod. Order No." <> '') then            SubcPriceManagement.GetSubcPriceForReqLine(Rec, "Subc. UoM for Pricelist");    end;}