// ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // ------------------------------------------------------------------------------------------------ namespace Microsoft.FixedAssets.Depreciation; using Microsoft.Finance.GeneralLedger.Setup; using Microsoft.FixedAssets.FixedAsset; using Microsoft.FixedAssets.Ledger; using Microsoft.FixedAssets.Maintenance; using Microsoft.FixedAssets.Setup; using System.Telemetry; table 5612 "FA Depreciation Book" { Caption = 'FA Depreciation Book'; Permissions = TableData "FA Ledger Entry" = r, TableData "Maintenance Ledger Entry" = r; DataClassification = CustomerContent; fields { field(1; "FA No."; Code[20]) { Caption = 'FA No.'; ToolTip = 'Specifies the number of the related fixed asset.'; NotBlank = true; TableRelation = "Fixed Asset"; } field(2; "Depreciation Book Code"; Code[10]) { Caption = 'Depreciation Book Code'; ToolTip = 'Specifies the code for the depreciation book to which the line will be posted if you have selected Fixed Asset in the Type field for this line.'; NotBlank = true; TableRelation = "Depreciation Book"; } field(3; "Depreciation Method"; Enum "FA Depreciation Method") { Caption = 'Depreciation Method'; ToolTip = 'Specifies how depreciation is calculated for the depreciation book.'; trigger OnValidate() begin ModifyDeprFields(); case "Depreciation Method" of "Depreciation Method"::"Straight-Line": begin "Declining-Balance %" := 0; "Depreciation Table Code" := ''; "First User-Defined Depr. Date" := 0D; "Use DB% First Fiscal Year" := false; end; "Depreciation Method"::"Declining-Balance 1", "Depreciation Method"::"Declining-Balance 2": begin "Straight-Line %" := 0; "No. of Depreciation Years" := 0; "No. of Depreciation Months" := 0; "Fixed Depr. Amount" := 0; "Depreciation Ending Date" := 0D; "Depreciation Table Code" := ''; "First User-Defined Depr. Date" := 0D; "Use DB% First Fiscal Year" := false; end; "Depreciation Method"::"DB1/SL", "Depreciation Method"::"DB2/SL": begin "Depreciation Table Code" := ''; "First User-Defined Depr. Date" := 0D; end; "Depreciation Method"::"User-Defined": begin "Straight-Line %" := 0; "No. of Depreciation Years" := 0; "No. of Depreciation Months" := 0; "Fixed Depr. Amount" := 0; "Depreciation Ending Date" := 0D; "Declining-Balance %" := 0; "Use DB% First Fiscal Year" := false; end; "Depreciation Method"::Manual: begin "Straight-Line %" := 0; "No. of Depreciation Years" := 0; "No. of Depreciation Months" := 0; "Fixed Depr. Amount" := 0; "Depreciation Ending Date" := 0D; "Declining-Balance %" := 0; "Depreciation Table Code" := ''; "First User-Defined Depr. Date" := 0D; "Use DB% First Fiscal Year" := false; end; end; TestHalfYearConventionMethod(); if "Depreciation Method" <> "Depreciation Method"::"Straight-Line" then begin DeprBook.Get("Depreciation Book Code"); if DeprBook."Use Accounting Period" then Error(MustBeStraightLineTxt, FieldCaption("Depreciation Method"), DeprBook.FieldCaption("Use Accounting Period"), true, DeprBook.TableCaption(), DeprBook.Code); end; end; } field(4; "Depreciation Starting Date"; Date) { Caption = 'Depreciation Starting Date'; ToolTip = 'Specifies the date on which depreciation of the fixed asset starts.'; Editable = true; trigger OnValidate() begin ModifyDeprFields(); VerifyBonusDepreciationEligibility(); ToggleUseBonusDepreciationOnChangingDepreciationStartingDate(); CalcDeprPeriod(); end; } field(5; "Straight-Line %"; Decimal) { AutoFormatType = 0; Caption = 'Straight-Line %'; ToolTip = 'Specifies the percentage to depreciate the fixed asset by the straight-line principle, but with a fixed yearly percentage.'; DecimalPlaces = 2 : 8; MinValue = 0; trigger OnValidate() begin ModifyDeprFields(); if ("Straight-Line %" <> 0) and not LinearMethod() then DeprMethodError(); AdjustLinearMethod("No. of Depreciation Years", "Fixed Depr. Amount"); end; } field(6; "No. of Depreciation Years"; Decimal) { AutoFormatType = 0; BlankZero = true; Caption = 'No. of Depreciation Years'; ToolTip = 'Specifies the length of the depreciation period, expressed in years.'; DecimalPlaces = 2 : 8; MinValue = 0; trigger OnValidate() var DeprBook2: Record "Depreciation Book"; IsHandled: Boolean; ShowDeprMethodError: Boolean; begin DeprBook2.Get("Depreciation Book Code"); OnBeforeValidateNoOfDepreYears("FA No.", DeprBook2, IsHandled); if not IsHandled then if DeprBook2."Fiscal Year 365 Days" then Error(FiscalYear365Err); IsHandled := false; OnValidateNoofDepreciationYearsOnBeforeTestFieldDeprStartingDate(Rec, IsHandled); if not IsHandled then TestField("Depreciation Starting Date"); ModifyDeprFields(); ShowDeprMethodError := ("No. of Depreciation Years" <> 0) and not LinearMethod(); OnValidateNoofDepreciationYearsOnAfterCalcShowDeprMethodError(Rec, ShowDeprMethodError); if ShowDeprMethodError then DeprMethodError(); "No. of Depreciation Months" := Round("No. of Depreciation Years" * 12, 0.00000001); AdjustLinearMethod("Straight-Line %", "Fixed Depr. Amount"); "Depreciation Ending Date" := CalcEndingDate(); end; } field(7; "No. of Depreciation Months"; Decimal) { AutoFormatType = 0; BlankZero = true; Caption = 'No. of Depreciation Months'; ToolTip = 'Specifies the length of the depreciation period, expressed in months.'; DecimalPlaces = 2 : 8; MinValue = 0; trigger OnValidate() var DeprBook2: Record "Depreciation Book"; IsHandled: Boolean; ShowDeprMethodError: Boolean; begin DeprBook2.Get("Depreciation Book Code"); OnBeforeValidateNoOfDeprMonths("FA No.", DeprBook2, IsHandled); if not IsHandled then if DeprBook2."Fiscal Year 365 Days" then Error(FiscalYear365Err); IsHandled := false; OnValidateNoofDepreciationMonthsOnBeforeTestFieldDeprStartingDate(Rec, IsHandled); if not IsHandled then TestField("Depreciation Starting Date"); ModifyDeprFields(); ShowDeprMethodError := ("No. of Depreciation Months" <> 0) and not LinearMethod(); OnValidateNoofDepreciationMonthsOnAfterCalcShowDeprMethodError(Rec, ShowDeprMethodError); if ShowDeprMethodError then DeprMethodError(); "No. of Depreciation Years" := Round("No. of Depreciation Months" / 12, 0.00000001); AdjustLinearMethod("Straight-Line %", "Fixed Depr. Amount"); "Depreciation Ending Date" := CalcEndingDate(); end; } field(8; "Fixed Depr. Amount"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); Caption = 'Fixed Depr. Amount'; ToolTip = 'Specifies an amount to depreciate the fixed asset, by a fixed yearly amount.'; MinValue = 0; trigger OnValidate() begin ModifyDeprFields(); if ("Fixed Depr. Amount" <> 0) and not LinearMethod() then DeprMethodError(); AdjustLinearMethod("Straight-Line %", "No. of Depreciation Years"); end; } field(9; "Declining-Balance %"; Decimal) { AutoFormatType = 0; Caption = 'Declining-Balance %'; ToolTip = 'Specifies the percentage to depreciate the fixed asset by the declining-balance principle, but with a fixed yearly percentage.'; DecimalPlaces = 2 : 8; MaxValue = 100; MinValue = 0; trigger OnValidate() begin if "Declining-Balance %" >= 100 then FieldError("Declining-Balance %", Text001); ModifyDeprFields(); if ("Declining-Balance %" <> 0) and not DecliningMethod() then DeprMethodError(); end; } field(10; "Depreciation Table Code"; Code[10]) { Caption = 'Depreciation Table Code'; ToolTip = 'Specifies the code of the depreciation table to use if you have selected the User-Defined option in the Depreciation Method field.'; TableRelation = "Depreciation Table Header"; trigger OnValidate() begin ModifyDeprFields(); if ("Depreciation Table Code" <> '') and not UserDefinedMethod() then DeprMethodError(); end; } field(11; "Final Rounding Amount"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); Caption = 'Final Rounding Amount'; ToolTip = 'Specifies the final rounding amount to use.'; MinValue = 0; trigger OnValidate() begin ModifyDeprFields(); end; } field(12; "Ending Book Value"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); Caption = 'Ending Book Value'; ToolTip = 'Specifies the amount to use as the ending book value.'; MinValue = 0; trigger OnValidate() begin ModifyDeprFields(); end; } field(13; "FA Posting Group"; Code[20]) { Caption = 'FA Posting Group'; ToolTip = 'Specifies which posting group is used for the depreciation book when posting fixed asset transactions.'; TableRelation = "FA Posting Group"; trigger OnValidate() begin ModifyDeprFields(); CheckFAPostingGroupChangeAfterAcquisition(); end; } field(14; "Depreciation Ending Date"; Date) { Caption = 'Depreciation Ending Date'; ToolTip = 'Specifies the date on which depreciation of the fixed asset ends.'; trigger OnValidate() var IsHandled: Boolean; ShowDeprMethodError: Boolean; begin IsHandled := false; OnValidateDepreciationEndingDateOnBeforeTestFieldDeprStartingDate(Rec, IsHandled); if not IsHandled then TestField("Depreciation Starting Date"); ShowDeprMethodError := ("Depreciation Ending Date" <> 0D) and not LinearMethod(); OnValidateDepreciationEndingDateOnAfterCalcShowDeprMethodError(Rec, ShowDeprMethodError); if ShowDeprMethodError then DeprMethodError(); ModifyDeprFields(); OnBeforeCalculateDepreEndingDate(Rec, "Depreciation Ending Date", IsHandled); if not IsHandled then CalcDeprPeriod(); end; } field(15; "Acquisition Cost"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const("Acquisition Cost"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Acquisition Cost'; ToolTip = 'Specifies the total acquisition cost for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(16; Depreciation; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const(Depreciation), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Depreciation'; ToolTip = 'Specifies the total depreciation for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(17; "Book Value"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "Part of Book Value" = const(true), "FA Posting Date" = field("FA Posting Date Filter"), "Derogatory Excluded" = const(false))); Caption = 'Book Value'; ToolTip = 'Specifies the book value for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(18; "Proceeds on Disposal"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const("Proceeds on Disposal"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Proceeds on Disposal'; ToolTip = 'Specifies the total proceeds on disposal for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(19; "Gain/Loss"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const("Gain/Loss"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Gain/Loss'; ToolTip = 'Specifies the total gain (credit) or loss (debit) for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(20; "Write-Down"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const("Write-Down"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Write-Down'; ToolTip = 'Specifies the total LCY amount of write-down entries for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(21; Appreciation; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const(Appreciation), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Appreciation'; ToolTip = 'Specifies the total appreciation for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(22; "Custom 1"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const("Custom 1"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Custom 1'; ToolTip = 'Specifies the total LCY amount for custom 1 entries for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(23; "Custom 2"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const("Custom 2"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Custom 2'; ToolTip = 'Specifies the total LCY amount for custom 2 entries for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(24; "Depreciable Basis"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "Part of Depreciable Basis" = const(true), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Depreciable Basis'; ToolTip = 'Specifies the depreciable basis amount for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(25; "Salvage Value"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const("Salvage Value"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Salvage Value'; ToolTip = 'Specifies the estimated residual value of a fixed asset when it can no longer be used.'; Editable = false; FieldClass = FlowField; } field(26; "Book Value on Disposal"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(Disposal), "FA Posting Type" = const("Book Value on Disposal"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Book Value on Disposal'; ToolTip = 'Specifies the total LCY amount of entries posted with the Book Value on Disposal posting type. Entries of this kind are created when you post disposal of a fixed asset to a depreciation book where the Gross method has been selected in the Disposal Calculation Method field.'; Editable = false; FieldClass = FlowField; } field(27; Maintenance; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("Maintenance Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "Maintenance Code" = field("Maintenance Code Filter"), "FA Posting Date" = field("FA Posting Date Filter"))); Caption = 'Maintenance'; ToolTip = 'Specifies the total maintenance cost for the fixed asset.'; Editable = false; FieldClass = FlowField; } field(28; "Maintenance Code Filter"; Code[10]) { Caption = 'Maintenance Code Filter'; FieldClass = FlowFilter; TableRelation = Maintenance; } field(29; "FA Posting Date Filter"; Date) { Caption = 'FA Posting Date Filter'; FieldClass = FlowFilter; } field(30; "Acquisition Date"; Date) { Caption = 'Acquisition Date'; ToolTip = 'Specifies the FA posting date of the first posted acquisition cost.'; Editable = false; } field(31; "G/L Acquisition Date"; Date) { Caption = 'G/L Acquisition Date'; ToolTip = 'Specifies the G/L posting date of the first posted acquisition cost.'; Editable = false; } field(32; "Disposal Date"; Date) { Caption = 'Disposal Date'; ToolTip = 'Specifies the FA posting date of the first posted disposal amount.'; Editable = false; } field(33; "Last Acquisition Cost Date"; Date) { Caption = 'Last Acquisition Cost Date'; ToolTip = 'Specifies the total percentage of acquisition cost that can be allocated when acquisition cost is posted.'; Editable = false; } field(34; "Last Depreciation Date"; Date) { Caption = 'Last Depreciation Date'; ToolTip = 'Specifies the FA posting date of the last posted depreciation.'; Editable = false; } field(35; "Last Write-Down Date"; Date) { Caption = 'Last Write-Down Date'; ToolTip = 'Specifies the FA posting date of the last posted write-down.'; Editable = false; } field(36; "Last Appreciation Date"; Date) { Caption = 'Last Appreciation Date'; ToolTip = 'Specifies the sum that applies to appreciations.'; Editable = false; } field(37; "Last Custom 1 Date"; Date) { Caption = 'Last Custom 1 Date'; ToolTip = 'Specifies the FA posting date of the last posted custom 1 entry.'; Editable = false; } field(38; "Last Custom 2 Date"; Date) { Caption = 'Last Custom 2 Date'; ToolTip = 'Specifies the FA posting date of the last posted custom 2 entry.'; Editable = false; } field(39; "Last Salvage Value Date"; Date) { Caption = 'Last Salvage Value Date'; ToolTip = 'Specifies if related salvage value entries are included in the batch job .'; Editable = false; } field(40; "FA Exchange Rate"; Decimal) { AutoFormatType = 0; Caption = 'FA Exchange Rate'; ToolTip = 'Specifies a decimal number, which will be used as an exchange rate when duplicating journal lines to this depreciation book.'; DecimalPlaces = 4 : 4; MinValue = 0; trigger OnValidate() begin ModifyDeprFields(); end; } field(41; "Fixed Depr. Amount below Zero"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); BlankZero = true; Caption = 'Fixed Depr. Amount below Zero'; ToolTip = 'Specifies a positive amount if you have selected the Allow Depr. below Zero field in the depreciation book.'; MinValue = 0; trigger OnValidate() begin ModifyDeprFields(); "Depr. below Zero %" := 0; if "Fixed Depr. Amount below Zero" > 0 then begin DeprBook.Get("Depreciation Book Code"); DeprBook.TestField("Allow Depr. below Zero", true); TestField("Use FA Ledger Check", true); end; end; } field(42; "Last Date Modified"; Date) { Caption = 'Last Date Modified'; Editable = false; } field(43; "First User-Defined Depr. Date"; Date) { Caption = 'First User-Defined Depr. Date'; ToolTip = 'Specifies the starting date for the user-defined depreciation table if you have entered a code in the Depreciation Table Code field.'; trigger OnValidate() begin ModifyDeprFields(); if ("First User-Defined Depr. Date" <> 0D) and not UserDefinedMethod() then DeprMethodError(); end; } field(44; "Use FA Ledger Check"; Boolean) { Caption = 'Use FA Ledger Check'; ToolTip = 'Specifies which checks to perform before posting a journal line.'; InitValue = true; trigger OnValidate() begin if not "Use FA Ledger Check" then begin DeprBook.Get("Depreciation Book Code"); DeprBook.TestField("Use FA Ledger Check", false); TestField("Fixed Depr. Amount below Zero", 0); TestField("Depr. below Zero %", 0); end; ModifyDeprFields(); end; } field(45; "Last Maintenance Date"; Date) { Caption = 'Last Maintenance Date'; Editable = false; } field(46; "Depr. below Zero %"; Decimal) { AutoFormatType = 0; BlankZero = true; Caption = 'Depr. below Zero %'; ToolTip = 'Specifies a percentage if you have selected the Allow Depr. below Zero field in the depreciation book.'; DecimalPlaces = 2 : 8; MinValue = 0; trigger OnValidate() begin ModifyDeprFields(); "Fixed Depr. Amount below Zero" := 0; if "Depr. below Zero %" > 0 then begin DeprBook.Get("Depreciation Book Code"); DeprBook.TestField("Allow Depr. below Zero", true); TestField("Use FA Ledger Check", true); end; end; } field(47; "Projected Disposal Date"; Date) { Caption = 'Projected Disposal Date'; ToolTip = 'Specifies the date on which you want to dispose of the fixed asset.'; } field(48; "Projected Proceeds on Disposal"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); BlankZero = true; Caption = 'Projected Proceeds on Disposal'; ToolTip = 'Specifies the expected proceeds from disposal of the fixed asset.'; MinValue = 0; } field(50; "Depr. Starting Date (Custom 1)"; Date) { Caption = 'Depr. Starting Date (Custom 1)'; trigger OnValidate() begin ModifyDeprFields(); end; } field(51; "Depr. Ending Date (Custom 1)"; Date) { Caption = 'Depr. Ending Date (Custom 1)'; trigger OnValidate() begin ModifyDeprFields(); end; } field(52; "Accum. Depr. % (Custom 1)"; Decimal) { AutoFormatType = 0; BlankZero = true; Caption = 'Accum. Depr. % (Custom 1)'; DecimalPlaces = 2 : 8; MaxValue = 100; MinValue = 0; trigger OnValidate() begin ModifyDeprFields(); end; } field(53; "Depr. This Year % (Custom 1)"; Decimal) { AutoFormatType = 0; BlankZero = true; Caption = 'Depr. This Year % (Custom 1)'; DecimalPlaces = 2 : 8; MaxValue = 100; MinValue = 0; } field(54; "Property Class (Custom 1)"; Option) { Caption = 'Property Class (Custom 1)'; OptionCaption = ' ,Personal Property,Real Property'; OptionMembers = " ","Personal Property","Real Property"; trigger OnValidate() begin ModifyDeprFields(); end; } field(55; Description; Text[100]) { Caption = 'Description'; ToolTip = 'Specifies the value in the Description field on the fixed asset card.'; Editable = false; } field(56; "Main Asset/Component"; Enum "FA Component Type") { Caption = 'Main Asset/Component'; Editable = false; } field(57; "Component of Main Asset"; Code[20]) { Caption = 'Component of Main Asset'; Editable = false; TableRelation = "Fixed Asset"; } field(58; "FA Add.-Currency Factor"; Decimal) { AutoFormatType = 0; Caption = 'FA Add.-Currency Factor'; DecimalPlaces = 0 : 15; MinValue = 0; } field(59; "Use Half-Year Convention"; Boolean) { Caption = 'Use Half-Year Convention'; ToolTip = 'Specifies that the Half-Year Convention is to be applied to the selected depreciation method.'; trigger OnValidate() begin ModifyDeprFields(); TestHalfYearConventionMethod(); end; } field(60; "Use DB% First Fiscal Year"; Boolean) { Caption = 'Use DB% First Fiscal Year'; ToolTip = 'Specifies that the depreciation methods DB1/SL and DB2/SL use the declining balance depreciation amount in the first fiscal year.'; trigger OnValidate() begin if "Use DB% First Fiscal Year" then if not (("Depreciation Method" = "Depreciation Method"::"DB1/SL") or ("Depreciation Method" = "Depreciation Method"::"DB2/SL")) then DeprMethodError(); end; } field(61; "Temp. Ending Date"; Date) { Caption = 'Temp. Ending Date'; ToolTip = 'Specifies the ending date of the period during which a temporary fixed depreciation amount will be used.'; } field(62; "Temp. Fixed Depr. Amount"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); Caption = 'Temp. Fixed Depr. Amount'; ToolTip = 'Specifies a temporary fixed depreciation amount.'; } field(63; "Ignore Def. Ending Book Value"; Boolean) { Caption = 'Ignore Def. Ending Book Value'; ToolTip = 'Specifies that the default ending book value is ignored, and the value in the Ending Book Value is used.'; trigger OnValidate() begin ModifyDeprFields(); end; } field(64; "Use Bonus Depreciation"; Boolean) { Caption = 'Use Bonus Depreciation'; ToolTip = 'Specifies if the bonus depreciation should be used in this book.'; trigger OnValidate() var FASetup: Record "FA Setup"; begin if Rec."Use Bonus Depreciation" then begin FASetup.Get(); if not FASetup.BonusDepreciationCorrectlySetup() then Error(BonusDepreciationNotSetupCorrectlyErr); if not EligibleForBonusDepreciation(FASetup) then Error(NotEligibleForBonusDepreciationErr); Rec.CalcFields(Depreciation); if Rec.Depreciation <> 0 then Error(CannotUseBonusDepreciationDepreciationStartedErr); Rec."Bonus Depreciation %" := GetApplicableBonusDeprPct(FASetup); end else begin Rec.CalcFields("Bonus Depr. Applied Amount"); if Rec."Bonus Depr. Applied Amount" <> 0 then Error(CannotTurnOffBonusDepreciationAlreadyAppliedErr); Rec."Bonus Depreciation %" := 0; end; end; } field(65; "Bonus Depr. Applied Amount"; Decimal) { Caption = 'Bonus Depreciation Applied Amount'; ToolTip = 'Specifies the amount of bonus depreciation that has been applied to the fixed asset.'; DecimalPlaces = 0 : 5; AutoFormatType = 0; FieldClass = FlowField; CalcFormula = sum("FA Ledger Entry"."Amount" where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const("FA Ledger Entry FA Posting Type"::"Bonus Depreciation"), "FA Posting Date" = field("FA Posting Date Filter"))); } field(66; "Bonus Depreciation %"; Decimal) { Caption = 'Bonus Depreciation %'; ToolTip = 'Specifies the bonus depreciation percentage for this fixed asset.'; DecimalPlaces = 0 : 2; MinValue = 0; MaxValue = 100; AutoFormatType = 0; trigger OnValidate() var FASetup: Record "FA Setup"; MaxPct: Decimal; begin if not Rec."Use Bonus Depreciation" then exit; Rec.CalcFields("Bonus Depr. Applied Amount"); if Rec."Bonus Depr. Applied Amount" <> 0 then Error(CannotTurnOffBonusDepreciationAlreadyAppliedErr); FASetup.Get(); MaxPct := GetApplicableBonusDeprPct(FASetup); if Rec."Bonus Depreciation %" > MaxPct then Error(BonusDeprPctExceedsMaxErr, MaxPct); end; } field(70; "Default FA Depreciation Book"; Boolean) { Caption = 'Default FA Depreciation Book'; ToolTip = 'Specifies the depreciation book that is used by default on documents and journals when a fixed asset has more than one depreciation book. A fixed asset can have only one default depreciation book. If a depreciation book is not specified for a fixed asset, the default depreciation book from the fixed asset setup is used.'; trigger OnValidate() var DefaultFADeprBook: Record "FA Depreciation Book"; begin if not "Default FA Depreciation Book" then exit; DefaultFADeprBook.SetRange("FA No.", "FA No."); DefaultFADeprBook.SetFilter("Depreciation Book Code", '<>%1', "Depreciation Book Code"); DefaultFADeprBook.SetRange("Default FA Depreciation Book", true); if not DefaultFADeprBook.IsEmpty() then FieldError("Default FA Depreciation Book", OnlyOneDefaultDeprBookErr); end; } field(5865; "Derogatory Amount"; Decimal) { AutoFormatType = 1; AutoFormatExpression = GetCurrencyCode(); CalcFormula = sum("FA Ledger Entry".Amount where("FA No." = field("FA No."), "Depreciation Book Code" = field("Depreciation Book Code"), "FA Posting Category" = const(" "), "FA Posting Type" = const(Derogatory), "FA Posting Date" = field("FA Posting Date Filter"), "Derogatory Excluded" = const(false))); Caption = 'Derogatory'; Editable = false; FieldClass = FlowField; ToolTip = 'Specifies the total derogatory depreciation for the fixed asset.'; } field(5866; "Last Derogatory"; Date) { Caption = 'Last Derogatory Date'; ToolTip = 'Specifies the FA posting date of the last posted derogatory depreciation.'; } } keys { key(Key1; "FA No.", "Depreciation Book Code") { Clustered = true; } key(Key2; "Depreciation Book Code", "FA No.") { } key(Key3; "Depreciation Book Code", "Component of Main Asset", "Main Asset/Component") { } key(Key4; "Main Asset/Component", "Depreciation Book Code") { } } fieldgroups { } trigger OnDelete() var IsHandled: Boolean; begin IsHandled := false; OnBeforeOnDelete(Rec, xRec, IsHandled); if IsHandled then exit; FAMoveEntries.MoveFAEntries(Rec); end; trigger OnInsert() var IsHandled: Boolean; begin "Acquisition Date" := 0D; "G/L Acquisition Date" := 0D; "Last Acquisition Cost Date" := 0D; "Last Salvage Value Date" := 0D; "Last Depreciation Date" := 0D; "Last Write-Down Date" := 0D; "Last Appreciation Date" := 0D; "Last Custom 1 Date" := 0D; "Last Custom 2 Date" := 0D; "Disposal Date" := 0D; "Last Maintenance Date" := 0D; LockTable(); FA.LockTable(); DeprBook.LockTable(); FA.Get("FA No."); DeprBook.Get("Depreciation Book Code"); Description := FA.Description; "Main Asset/Component" := FA."Main Asset/Component"; "Component of Main Asset" := FA."Component of Main Asset"; OnBeforeInsertFADeprBook(Rec, IsHandled); if not IsHandled then if ("No. of Depreciation Years" <> 0) or ("No. of Depreciation Months" <> 0) then DeprBook.TestField("Fiscal Year 365 Days", false); CheckApplyDeprBookDefaults(); end; trigger OnModify() var IsHandled: Boolean; begin "Last Date Modified" := Today; LockTable(); DeprBook.LockTable(); DeprBook.Get("Depreciation Book Code"); IsHandled := false; OnBeforeModifyFADeprBook(Rec, IsHandled); if not IsHandled then if ("No. of Depreciation Years" <> 0) or ("No. of Depreciation Months" <> 0) then DeprBook.TestField("Fiscal Year 365 Days", false); CheckApplyDeprBookDefaults(); end; trigger OnRename() begin Error(Text000, TableCaption); end; var FAMoveEntries: Codeunit "FA MoveEntries"; FADateCalculation: Codeunit "FA Date Calculation"; DepreciationCalculation: Codeunit "Depreciation Calculation"; #pragma warning disable AA0074 #pragma warning disable AA0470 Text000: Label 'You cannot rename a %1.'; #pragma warning restore AA0470 Text001: Label 'must not be 100'; #pragma warning disable AA0470 Text002: Label '%1 is later than %2.'; Text003: Label 'must not be %1'; #pragma warning restore AA0470 Text004: Label 'untitled'; #pragma warning restore AA0074 OnlyOneDefaultDeprBookErr: Label 'Only one fixed asset depreciation book can be marked as the default book'; FiscalYear365Err: Label 'An ending date for depreciation cannot be calculated automatically when the Fiscal Year 365 Days option is chosen. You must manually enter the ending date.'; MustBeStraightLineTxt: Label '%1 must be Straight-Line if %2 is %3 in %4: %5.', Comment = '%1="Depreciation Method" Field Caption %2="Use Accounting Period" Field Caption %3="Use Accounting Period" Field Value %4="Depreciation Book" Table Caption %5="Depreciation Book" Value of field Code'; CannotUseBonusDepreciationDepreciationStartedErr: Label 'Bonus depreciation cannot be used because depreciation has already started for this fixed asset.'; NotEligibleForBonusDepreciationErr: Label 'This fixed asset is not eligible for bonus depreciation.'; BonusDepreciationNotSetupCorrectlyErr: Label 'You must open Fixed Asset Setup and set up the effective date and percentage for bonus depreciation.'; CannotTurnOffBonusDepreciationAlreadyAppliedErr: Label 'Bonus depreciation has already been applied to this fixed asset.'; BonusDepreciationAlreadyAppliedErr: Label 'The bonus depreciation has already been applied for this depreciation book. This change is making the fixed asset not eligible for bonus depreciation.'; BonusDepreciationTurnedOnErr: Label 'You must uncheck Use Bonus Depreciation, because this change is making the fixed asset not eligible for bonus depreciation.'; BonusDeprPctExceedsMaxErr: Label 'The bonus depreciation percentage cannot exceed the applicable maximum of %1%.', Comment = '%1 = maximum percentage'; CannotChangeFAPostingGroupAfterAcquisitionErr: Label 'You cannot change the %1 for fixed asset %2 because acquisition cost has already been posted in depreciation book %3. To move the fixed asset to another posting group, use the FA reclassification journal, or turn on the %4 toggle for the depreciation book.', Comment = '%1 = FA Posting Group field caption, %2 = fixed asset number, %3 = depreciation book code, %4 = Allow Changes in Depr. Fields field caption'; protected var FA: Record "Fixed Asset"; DeprBook: Record "Depreciation Book"; procedure EligibleForBonusDepreciation(FASetup: Record "FA Setup"): Boolean var AdvBonusDeprSetup: Record "Adv. Bonus Depreciation Setup"; FixedAsset: Record "Fixed Asset"; FAClassCode: Code[10]; begin if not FASetup.BonusDepreciationCorrectlySetup() then exit(false); if Rec."Depreciation Starting Date" = 0D then exit(false); if Rec."Depreciation Starting Date" >= FASetup."Bonus Depr. Effective Date" then exit(true); FixedAsset.SetLoadFields("FA Class Code"); if FixedAsset.Get(Rec."FA No.") then FAClassCode := FixedAsset."FA Class Code"; AdvBonusDeprSetup.SetCurrentKey("Effective Date", "FA Class Code"); AdvBonusDeprSetup.SetFilter("Effective Date", '<=%1', Rec."Depreciation Starting Date"); AdvBonusDeprSetup.SetFilter("FA Class Code", '%1|%2', '', FAClassCode); if not AdvBonusDeprSetup.IsEmpty() then exit(true); exit(false); end; local procedure AdjustLinearMethod(var Amount1: Decimal; var Amount2: Decimal) var IsHandled: Boolean; begin IsHandled := false; OnBeforeAdjustLinearMethod(Rec, Amount1, Amount2, IsHandled); if IsHandled then exit; Amount1 := 0; Amount2 := 0; if "No. of Depreciation Years" = 0 then begin "No. of Depreciation Months" := 0; "Depreciation Ending Date" := 0D; end; end; local procedure ModifyDeprFields() var IsHandled: Boolean; begin IsHandled := false; OnBeforeModifyDeprFields(Rec, IsHandled); if not IsHandled then if ("Last Depreciation Date" > 0D) or ("Last Write-Down Date" > 0D) or ("Last Appreciation Date" > 0D) or ("Last Custom 1 Date" > 0D) or ("Last Custom 2 Date" > 0D) or ("Disposal Date" > 0D) then begin DeprBook.Get("Depreciation Book Code"); DeprBook.TestField("Allow Changes in Depr. Fields", true); end; OnAfterModifyDeprFields(Rec); end; local procedure CheckFAPostingGroupChangeAfterAcquisition() var FADepreciationBook: Record "FA Depreciation Book"; begin // Compare with the stored record, because acquisition cost has already been posted to the G/L accounts of the stored posting group. if not FADepreciationBook.Get("FA No.", "Depreciation Book Code") then exit; if (FADepreciationBook."Last Acquisition Cost Date" = 0D) or (FADepreciationBook."FA Posting Group" = '') or (FADepreciationBook."FA Posting Group" = "FA Posting Group") then exit; DeprBook.Get("Depreciation Book Code"); if not DeprBook."Allow Changes in Depr. Fields" then Error( CannotChangeFAPostingGroupAfterAcquisitionErr, FieldCaption("FA Posting Group"), "FA No.", "Depreciation Book Code", DeprBook.FieldCaption("Allow Changes in Depr. Fields")); end; internal procedure BonusDepreciationApplied(): Boolean var FALedgerEntry: Record "FA Ledger Entry"; begin FALedgerEntry.ReadIsolation(IsolationLevel::ReadCommitted); FALedgerEntry.SetCurrentKey("FA No.", "Depreciation Book Code", "FA Posting Category", "FA Posting Type"); FALedgerEntry.SetRange("FA No.", Rec."FA No."); FALedgerEntry.SetRange("Depreciation Book Code", Rec."Depreciation Book Code"); FALedgerEntry.SetRange("FA Posting Category", FALedgerEntry."FA Posting Category"::" "); FALedgerEntry.SetRange("FA Posting Type", "FA Ledger Entry FA Posting Type"::"Bonus Depreciation"); exit(not FALedgerEntry.IsEmpty()); end; local procedure VerifyBonusDepreciationEligibility() var FASetup: Record "FA Setup"; begin if not Rec."Use Bonus Depreciation" then exit; FASetup.Get(); if not Rec.EligibleForBonusDepreciation(FASetup) then Error(BonusDepreciationTurnedOnErr); if (Rec."Depreciation Starting Date" = 0D) or (FASetup."Bonus Depr. Effective Date" = 0D) then Error(BonusDepreciationAlreadyAppliedErr); if Rec."Depreciation Starting Date" < FASetup."Bonus Depr. Effective Date" then if Rec.BonusDepreciationApplied() then Error(BonusDepreciationAlreadyAppliedErr); end; local procedure ToggleUseBonusDepreciationOnChangingDepreciationStartingDate() var FASetup: Record "FA Setup"; DepreciationBook: Record "Depreciation Book"; FeatureTelemetry: Codeunit "Feature Telemetry"; begin DepreciationBook.Get(Rec."Depreciation Book Code"); if not DepreciationBook."Use Bonus Depreciation" then exit; FASetup.Get(); if not FASetup.BonusDepreciationCorrectlySetup() then exit; if Rec."Depreciation Starting Date" = 0D then begin Rec."Use Bonus Depreciation" := false; Rec."Bonus Depreciation %" := 0; exit; end; if Rec.EligibleForBonusDepreciation(FASetup) then begin Rec."Use Bonus Depreciation" := true; Rec."Bonus Depreciation %" := GetApplicableBonusDeprPct(FASetup); FeatureTelemetry.LogUsage('0000SEM', 'Fixed Asset', 'Using Bonus Depreciation'); end else begin Rec."Use Bonus Depreciation" := false; Rec."Bonus Depreciation %" := 0; end; end; procedure CalcDeprPeriod() var DepreciationBook2: Record "Depreciation Book"; IsHandled: Boolean; begin IsHandled := false; OnBeforeCalcDeprPeriod(Rec, IsHandled); if not IsHandled then begin if "Depreciation Starting Date" = 0D then begin "Depreciation Ending Date" := 0D; "No. of Depreciation Years" := 0; "No. of Depreciation Months" := 0; end; if ("Depreciation Starting Date" = 0D) or ("Depreciation Ending Date" = 0D) then begin "No. of Depreciation Years" := 0; "No. of Depreciation Months" := 0; end else begin if "Depreciation Starting Date" > "Depreciation Ending Date" then Error( Text002, FieldCaption("Depreciation Starting Date"), FieldCaption("Depreciation Ending Date")); DepreciationBook2.Get("Depreciation Book Code"); if DepreciationBook2."Fiscal Year 365 Days" then begin "No. of Depreciation Months" := 0; "No. of Depreciation Years" := 0; end; if not DepreciationBook2."Fiscal Year 365 Days" then begin "No. of Depreciation Months" := DepreciationCalculation.DeprDays("Depreciation Starting Date", "Depreciation Ending Date", false, DeprBook."Use Accounting Period") / 30; "No. of Depreciation Months" := Round("No. of Depreciation Months", 0.00000001); "No. of Depreciation Years" := Round("No. of Depreciation Months" / 12, 0.00000001); end; "Straight-Line %" := 0; "Fixed Depr. Amount" := 0; end; end; OnAfterCalcDeprPeriod(Rec); end; procedure CalcEndingDate() EndingDate: Date begin if "No. of Depreciation Years" = 0 then EndingDate := 0D else begin EndingDate := FADateCalculation.CalculateDate( "Depreciation Starting Date", Round("No. of Depreciation Years" * 360, 1), false); DeprBook.Get("Depreciation Book Code"); EndingDate := DepreciationCalculation.Yesterday(EndingDate, false, DeprBook."Use Accounting Period"); if EndingDate < "Depreciation Starting Date" then EndingDate := "Depreciation Starting Date"; end; OnAfterCalcEndingDate(Rec, EndingDate); end; procedure GetExchangeRate(): Decimal var DepreciationBook: Record "Depreciation Book"; begin DepreciationBook.Get("Depreciation Book Code"); if not DepreciationBook."Use FA Exch. Rate in Duplic." then exit(0); if "FA Exchange Rate" > 0 then exit("FA Exchange Rate"); exit(DepreciationBook."Default Exchange Rate"); end; protected procedure LinearMethod() Result: Boolean begin Result := "Depreciation Method" in ["Depreciation Method"::"Straight-Line", "Depreciation Method"::"DB1/SL", "Depreciation Method"::"DB2/SL"]; OnAfterLinearMethod(Rec, Result); end; protected procedure DecliningMethod(): Boolean begin exit( "Depreciation Method" in ["Depreciation Method"::"Declining-Balance 1", "Depreciation Method"::"Declining-Balance 2", "Depreciation Method"::"DB1/SL", "Depreciation Method"::"DB2/SL"]); end; protected procedure UserDefinedMethod() Result: Boolean begin Result := Rec."Depreciation Method" = Rec."Depreciation Method"::"User-Defined"; OnAfterUserDefinedMethod(Rec, Result); end; protected procedure TestHalfYearConventionMethod() begin if "Depreciation Method" in ["Depreciation Method"::"Declining-Balance 2", "Depreciation Method"::"DB2/SL", "Depreciation Method"::"User-Defined"] then TestField("Use Half-Year Convention", false); end; local procedure DeprMethodError() begin FieldError("Depreciation Method", StrSubstNo(Text003, "Depreciation Method")); end; local procedure CheckApplyDeprBookDefaults() var IsHandled: Boolean; begin IsHandled := false; OnBeforeCheckApplyDeprBookDefaults(Rec, IsHandled); if IsHandled then exit; if not "Ignore Def. Ending Book Value" and (DeprBook."Default Ending Book Value" <> 0) and ("Ending Book Value" = 0) then "Ending Book Value" := DeprBook."Default Ending Book Value"; if (DeprBook."Default Final Rounding Amount" <> 0) and ("Final Rounding Amount" = 0) then "Final Rounding Amount" := DeprBook."Default Final Rounding Amount" end; procedure Caption(): Text var FixedAsset: Record "Fixed Asset"; DepreciationBook: Record "Depreciation Book"; begin if "FA No." = '' then exit(Text004); FixedAsset.Get("FA No."); DepreciationBook.Get("Depreciation Book Code"); exit( StrSubstNo( '%1 %2 %3 %4', "FA No.", FixedAsset.Description, "Depreciation Book Code", DepreciationBook.Description)); end; procedure DrillDownOnBookValue() var FALedgerEntry: Record "FA Ledger Entry"; IsHandled: Boolean; begin IsHandled := false; OnBeforeDrillDownOnBookValue(Rec, IsHandled); if IsHandled then exit; if "Disposal Date" > 0D then ShowBookValueAfterDisposal() else begin SetBookValueFiltersOnFALedgerEntry(FALedgerEntry); PAGE.Run(0, FALedgerEntry); end; end; internal procedure DrillDownOnAcquisitionCost() var FALedgerEntry: Record "FA Ledger Entry"; begin SetAcquisitionCostFiltersOnFALedgerEntry(FALedgerEntry); PAGE.Run(0, FALedgerEntry); end; internal procedure DrillDownOnBonusDeprAppliedAmount() var FALedgerEntry: Record "FA Ledger Entry"; begin SetBonusDepreciationFiltersOnFALedgerEntry(FALedgerEntry); PAGE.Run(0, FALedgerEntry); end; procedure ShowBookValueAfterDisposal() var TempFALedgerEntry: Record "FA Ledger Entry" temporary; FALedgerEntry: Record "FA Ledger Entry"; IsHandled: Boolean; begin IsHandled := false; OnBeforeShowBookValueAfterDisposal(Rec, IsHandled); if IsHandled then exit; if "Disposal Date" > 0D then begin Clear(TempFALedgerEntry); TempFALedgerEntry.DeleteAll(); TempFALedgerEntry.SetCurrentKey("FA No.", "Depreciation Book Code", "FA Posting Date"); DepreciationCalculation.SetFAFilter(FALedgerEntry, "FA No.", "Depreciation Book Code", false); SetBookValueAfterDisposalFiltersOnFALedgerEntry(FALedgerEntry); PAGE.Run(0, FALedgerEntry); end else begin SetBookValueFiltersOnFALedgerEntry(FALedgerEntry); PAGE.Run(0, FALedgerEntry); end; end; procedure CalcBookValue() var IsHandled: Boolean; begin IsHandled := false; OnBeforeCalcBookValue(Rec, IsHandled); if IsHandled then exit; if "Disposal Date" > 0D then "Book Value" := 0 else CalcFields("Book Value"); end; procedure SetBookValueFiltersOnFALedgerEntry(var FALedgerEntry: Record "FA Ledger Entry") begin FALedgerEntry.SetCurrentKey("FA No.", "Depreciation Book Code", "Part of Book Value", "FA Posting Date"); FALedgerEntry.SetRange("FA No.", "FA No."); FALedgerEntry.SetRange("Depreciation Book Code", "Depreciation Book Code"); FALedgerEntry.SetRange("Part of Book Value", true); FALedgerEntry.SetRange("Derogatory Excluded", false); OnAfterSetBookValueFiltersOnFALedgerEntry(FALedgerEntry); end; internal procedure SetAcquisitionCostFiltersOnFALedgerEntry(var FALedgerEntry: Record "FA Ledger Entry") begin FALedgerEntry.SetCurrentKey("FA No.", "Depreciation Book Code", "FA Posting Category", "FA Posting Type", "FA Posting Date"); FALedgerEntry.SetRange("FA No.", "FA No."); FALedgerEntry.SetRange("Depreciation Book Code", "Depreciation Book Code"); FALedgerEntry.SetRange("FA Posting Category", FALedgerEntry."FA Posting Category"::" "); FALedgerEntry.SetRange("FA Posting Type", FALedgerEntry."FA Posting Type"::"Acquisition Cost") end; internal procedure SetBonusDepreciationFiltersOnFALedgerEntry(var FALedgerEntry: Record "FA Ledger Entry") begin FALedgerEntry.SetCurrentKey("FA No.", "Depreciation Book Code", "FA Posting Category", "FA Posting Type", "FA Posting Date"); FALedgerEntry.SetRange("FA No.", "FA No."); FALedgerEntry.SetRange("Depreciation Book Code", "Depreciation Book Code"); FALedgerEntry.SetRange("FA Posting Category", FALedgerEntry."FA Posting Category"::" "); FALedgerEntry.SetRange("FA Posting Type", FALedgerEntry."FA Posting Type"::"Bonus Depreciation") end; procedure LineIsReadyForAcquisition(FANo: Code[20]): Boolean var FADepreciationBook: Record "FA Depreciation Book"; FASetup: Record "FA Setup"; begin FASetup.Get(); exit(FADepreciationBook.Get(FANo, FASetup."Default Depr. Book") and FADepreciationBook.RecIsReadyForAcquisition()); end; procedure RecIsReadyForAcquisition(): Boolean var FASetup: Record "FA Setup"; begin FASetup.Get(); if ("Depreciation Book Code" = FASetup."Default Depr. Book") and ("FA Posting Group" <> '') and ("Depreciation Starting Date" > 0D) then begin if "Depreciation Method" in ["Depreciation Method"::"Straight-Line", "Depreciation Method"::"DB1/SL", "Depreciation Method"::"DB2/SL"] then exit(("No. of Depreciation Years" > 0) or ("Depreciation Ending Date" <> 0D)); exit(true); end; exit(false); end; procedure UpdateBookValue() var IsHandled: Boolean; begin IsHandled := false; OnBeforeUpdateBookValue(Rec, IsHandled); if IsHandled then exit; if "Disposal Date" > 0D then "Book Value" := 0; end; local procedure GetApplicableBonusDeprPct(FASetup: Record "FA Setup"): Decimal var AdvBonusDeprSetup: Record "Adv. Bonus Depreciation Setup"; FixedAsset: Record "Fixed Asset"; FAClassCode: Code[10]; BestPct: Decimal; BestDate: Date; begin FixedAsset.SetLoadFields("FA Class Code"); if FixedAsset.Get(Rec."FA No.") then FAClassCode := FixedAsset."FA Class Code"; if FASetup."Bonus Depr. Effective Date" <= Rec."Depreciation Starting Date" then begin BestPct := FASetup."Bonus Depreciation %"; BestDate := FASetup."Bonus Depr. Effective Date"; end; AdvBonusDeprSetup.SetCurrentKey("Effective Date", "FA Class Code"); AdvBonusDeprSetup.SetFilter("Effective Date", '<=%1', Rec."Depreciation Starting Date"); if AdvBonusDeprSetup.FindSet() then repeat if (AdvBonusDeprSetup."FA Class Code" = '') or (AdvBonusDeprSetup."FA Class Code" = FAClassCode) then if AdvBonusDeprSetup."Effective Date" >= BestDate then begin BestPct := AdvBonusDeprSetup."Bonus Depreciation %"; BestDate := AdvBonusDeprSetup."Effective Date"; end; until AdvBonusDeprSetup.Next() = 0; exit(BestPct); end; internal procedure BonusDepreciationAmount(): Decimal var GeneralLedgerSetup: Record "General Ledger Setup"; begin GeneralLedgerSetup.Get(); Rec.CalcFields("Acquisition Cost"); exit(Round(Rec."Acquisition Cost" * Rec."Bonus Depreciation %" * 0.01, GeneralLedgerSetup."Amount Rounding Precision")); end; local procedure SetBookValueAfterDisposalFiltersOnFALedgerEntry(var FALedgerEntry: Record "FA Ledger Entry") begin SetBookValueFiltersOnFALedgerEntry(FALedgerEntry); FALedgerEntry.SetRange("Part of Book Value"); if GetFilter("FA Posting Date Filter") <> '' then FALedgerEntry.SetFilter("FA Posting Date", GetFilter("FA Posting Date Filter")); end; internal procedure GetCurrencyCode(): Code[10] begin exit(''); end; [IntegrationEvent(false, false)] local procedure OnAfterCalcDeprPeriod(var FADepreciationBook: Record "FA Depreciation Book") begin end; [IntegrationEvent(false, false)] local procedure OnAfterLinearMethod(var FADepreciationBook: Record "FA Depreciation Book"; var Result: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnAfterCalcEndingDate(FADepreciationBook: Record "FA Depreciation Book"; var EndingDate: Date) begin end; [IntegrationEvent(false, false)] local procedure OnAfterUserDefinedMethod(FADepreciationBook: Record "FA Depreciation Book"; var Result: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeOnDelete(var FADeprecBook: Record "FA Depreciation Book"; xFADeprecBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeAdjustLinearMethod(var FADepreciationBook: Record "FA Depreciation Book"; var Amount1: Decimal; var Amount2: Decimal; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnAfterSetBookValueFiltersOnFALedgerEntry(var FALedgerEntry: Record "FA Ledger Entry") begin end; [IntegrationEvent(false, false)] local procedure OnBeforeShowBookValueAfterDisposal(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeCalcDeprPeriod(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeCalcBookValue(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeUpdateBookValue(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeModifyDeprFields(FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeDrillDownOnBookValue(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeValidateNoOfDepreYears(FANo: Code[20]; DeprecBook: Record "Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeValidateNoOfDeprMonths(FANo: Code[20]; DeprecBook: Record "Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeCalculateDepreEndingDate(var FADeprBook: Record "FA Depreciation Book"; DeprEndDate: Date; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeModifyFADeprBook(FADepreBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnValidateNoofDepreciationYearsOnAfterCalcShowDeprMethodError(var FADepreciationBook: Record "FA Depreciation Book"; var ShowDeprMethodError: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnValidateDepreciationEndingDateOnAfterCalcShowDeprMethodError(var FADepreciationBook: Record "FA Depreciation Book"; var ShowDeprMethodError: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnValidateNoofDepreciationMonthsOnAfterCalcShowDeprMethodError(var FADepreciationBook: Record "FA Depreciation Book"; var ShowDeprMethodError: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeInsertFADeprBook(FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnBeforeCheckApplyDeprBookDefaults(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnValidateDepreciationEndingDateOnBeforeTestFieldDeprStartingDate(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnValidateNoofDepreciationYearsOnBeforeTestFieldDeprStartingDate(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(false, false)] local procedure OnValidateNoofDepreciationMonthsOnBeforeTestFieldDeprStartingDate(var FADepreciationBook: Record "FA Depreciation Book"; var IsHandled: Boolean) begin end; [IntegrationEvent(true, false)] local procedure OnAfterModifyDeprFields(var FADepreciationBook: Record "FA Depreciation Book") begin end; }