diff --git a/build/groups.json b/build/groups.json index e4b7555d17a..e37e7dd2395 100644 --- a/build/groups.json +++ b/build/groups.json @@ -1750,6 +1750,22 @@ } ] }, + { + "name": "Depreciation Differences FI", + "groups": [ + { + "name": "LocalBaseExtensions" + } + ] + }, + { + "name": "Depreciation Differences FI Tests", + "groups": [ + { + "name": "LocalBaseExtensions" + } + ] + }, { "name": "DK Core", "groups": [ diff --git a/build/projects.json b/build/projects.json index 040fb3765d2..9c070b58842 100644 --- a/build/projects.json +++ b/build/projects.json @@ -2031,6 +2031,28 @@ "ruleSetPathMinorRelease": "$ENV:INETROOT\\App\\Rulesets\\MinorRelease\\app.ruleset.json", "owningteam": "\\AI Business Solutions\\Finance" }, + "Depreciation Differences FI": { + "projectPath": "$env:INETROOT\\App\\Apps\\FI\\DepreciationDifferencesFI\\app", + "dvdFolder": "Applications\\DepreciationDifferencesFI\\Source", + "hasTranslations": true, + "installOnEnvironmentUpdate": true, + "supportedCountries": "FI", + "runStaticCodeAnalysis": true, + "logLevel": "warning", + "ruleSetPath": "$ENV:INETROOT\\App\\Rulesets\\app.ruleset.json", + "ruleSetPathMinorRelease": "$ENV:INETROOT\\App\\Rulesets\\MinorRelease\\app.ruleset.json" + }, + "Depreciation Differences FI Tests": { + "projectPath": "$env:INETROOT\\App\\Apps\\FI\\DepreciationDifferencesFI\\test", + "dvdFolder": "Applications\\DepreciationDifferencesFI\\Test", + "supportedCountries": "FI", + "isTest": true, + "runStaticCodeAnalysis": true, + "logLevel": "warning", + "ruleSetPath": "$ENV:INETROOT\\App\\Rulesets\\app.ruleset.json", + "ruleSetPathMinorRelease": "$ENV:INETROOT\\App\\Rulesets\\MinorRelease\\app.ruleset.json", + "owningteam": "\\AI Business Solutions\\Finance" + }, "DK Core": { "projectPath": "$env:INETROOT\\App\\Apps\\DK\\DKCore\\app", "dvdFolder": "Applications\\DKCore\\Source", diff --git a/src/Apps/FI/ContosoCoffeeDemoDatasetFI/app/DemoData/FixedAsset/1.Setup Data/CreateFAPostingGrpFI.Codeunit.al b/src/Apps/FI/ContosoCoffeeDemoDatasetFI/app/DemoData/FixedAsset/1.Setup Data/CreateFAPostingGrpFI.Codeunit.al index cc359e7ebc3..518113429a1 100644 --- a/src/Apps/FI/ContosoCoffeeDemoDatasetFI/app/DemoData/FixedAsset/1.Setup Data/CreateFAPostingGrpFI.Codeunit.al +++ b/src/Apps/FI/ContosoCoffeeDemoDatasetFI/app/DemoData/FixedAsset/1.Setup Data/CreateFAPostingGrpFI.Codeunit.al @@ -6,6 +6,7 @@ namespace Microsoft.DemoData.FixedAsset; using Microsoft.DemoData.Finance; +using Microsoft.FixedAssets.Depreciation; using Microsoft.FixedAssets.FixedAsset; codeunit 13445 "Create FA Posting Grp. FI" @@ -32,8 +33,21 @@ codeunit 13445 "Create FA Posting Grp. FI" end; local procedure ValidateRecordFields(var FAPostingGroup: Record "FA Posting Group"; DeprDifferenceAcc: Code[20]; DeprDifferenceBalAcc: Code[20]) +#if not CLEAN29 + var + DepreciationDifferencesFIFeature: Codeunit "Depreciation Differences FI Feature"; +#endif begin - FAPostingGroup.Validate("Depr. Difference Acc.", DeprDifferenceAcc); - FAPostingGroup.Validate("Depr. Difference Bal. Acc.", DeprDifferenceBalAcc); +#if not CLEAN29 + if not DepreciationDifferencesFIFeature.IsEnabled() then begin +#pragma warning disable AL0432 + FAPostingGroup.Validate("Depr. Difference Acc.", DeprDifferenceAcc); + FAPostingGroup.Validate("Depr. Difference Bal. Acc.", DeprDifferenceBalAcc); +#pragma warning restore AL0432 + exit; + end; +#endif + FAPostingGroup.Validate("Depreciation Difference Account", DeprDifferenceAcc); + FAPostingGroup.Validate("Depreciation Difference Bal Acct", DeprDifferenceBalAcc); end; } diff --git a/src/Apps/FI/ContosoCoffeeDemoDatasetFI/app/app.json b/src/Apps/FI/ContosoCoffeeDemoDatasetFI/app/app.json index d591d3d010d..de8dc47ae18 100644 --- a/src/Apps/FI/ContosoCoffeeDemoDatasetFI/app/app.json +++ b/src/Apps/FI/ContosoCoffeeDemoDatasetFI/app/app.json @@ -17,6 +17,12 @@ "name": "Contoso Coffee Demo Dataset", "publisher": "Microsoft", "version": "29.0.0.0" + }, + { + "id": "ecb1100e-3081-4c6a-9554-de33c687bf5f", + "name": "Depreciation Differences FI", + "publisher": "Microsoft", + "version": "$(app_currentVersion)" } ], "screenshots": [], diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/ExtensionLogo.png b/src/Apps/FI/DepreciationDifferencesFI/app/ExtensionLogo.png new file mode 100644 index 00000000000..4d2c9a626cb Binary files /dev/null and b/src/Apps/FI/DepreciationDifferencesFI/app/ExtensionLogo.png differ diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/app.json b/src/Apps/FI/DepreciationDifferencesFI/app/app.json new file mode 100644 index 00000000000..f7ea3e2e62a --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/app.json @@ -0,0 +1,41 @@ +{ + "id": "ecb1100e-3081-4c6a-9554-de33c687bf5f", + "name": "Depreciation Differences FI", + "publisher": "Microsoft", + "version": "$(app_currentVersion)", + "brief": "First-party app for FI depreciation differences in Business Central.", + "description": "Implements Finnish posting depreciation differences functionality in Business Central.", + "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", + "EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", + "help": "https://go.microsoft.com/fwlink/?linkid=2212316", + "url": "https://go.microsoft.com/fwlink/?LinkId=724011", + "logo": "ExtensionLogo.png", + "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2212316", + "application": "$(app_minimumVersion)", + "platform": "$(app_platformVersion)", + "dependencies": [], + "internalsVisibleTo": [ + { + "id": "a6ac48f2-7b89-47fe-bb24-a9f722e6fec0", + "name": "Depreciation Differences FI Tests", + "publisher": "Microsoft" + } + ], + "screenshots": [], + "target": "OnPrem", + "idRanges": [ + { + "from": 13462, + "to": 13485 + } + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "allowDownloadingSource": true, + "includeSourceInSymbolFile": true + }, + "features": [ + "NoImplicitWith", + "TranslationFile" + ] +} \ No newline at end of file diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/permissions/DepreciationDifferencesFIObjects.PermissionSetExt.al b/src/Apps/FI/DepreciationDifferencesFI/app/permissions/DepreciationDifferencesFIObjects.PermissionSetExt.al new file mode 100644 index 00000000000..ef478055b0f --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/permissions/DepreciationDifferencesFIObjects.PermissionSetExt.al @@ -0,0 +1,23 @@ +// ------------------------------------------------------------------------------------------------ +// 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; + +permissionsetextension 13485 "Dep Diff FI - Objects" extends "D365 BASIC" +{ + Permissions = + tabledata "Depr. Diff. Posting Buffer" = RIMD, + table "Depr. Diff. Posting Buffer" = X, + report "Calc. and Post Depr. Diff." = X, + codeunit "Depreciation Differences FI Subscribers" = X, +#if not CLEAN29 + codeunit "Depreciation Differences FI Feature" = X, + codeunit "Dep Diff FI Feature Data Update" = X, +#endif +#if CLEAN29 + codeunit "Upgrade Depreciation Diff. FI" = X, +#endif + codeunit "Dep Diff FI Upgrade Tag" = X; +} diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepDiffFIFeatureDataUpdate.Codeunit.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepDiffFIFeatureDataUpdate.Codeunit.al new file mode 100644 index 00000000000..52ef415e532 --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepDiffFIFeatureDataUpdate.Codeunit.al @@ -0,0 +1,141 @@ +#if not CLEAN29 +// ------------------------------------------------------------------------------------------------ +// 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.Foundation.Navigate; +using System.Environment.Configuration; +using System.Upgrade; + +codeunit 13468 "Dep Diff FI Feature Data Update" implements "Feature Data Update" +{ + Access = Internal; + Permissions = tabledata "Feature Data Update Status" = rm; + InherentEntitlements = X; + InherentPermissions = X; + ObsoleteReason = 'Feature Depreciation Differences FI will be enabled by default in version 32.0.'; + ObsoleteState = Pending; + ObsoleteTag = '29.0'; + + var + TempDocumentEntry: Record "Document Entry" temporary; + DescriptionTxt: Label 'Existing records in FI BaseApp fields will be copied to Depreciation Differences FI app fields.'; + + procedure IsDataUpdateRequired(): Boolean + begin + CountRecords(); + if TempDocumentEntry.IsEmpty() then begin + SetUpgradeTag(false); + exit(false); + end; + exit(true); + end; + + procedure ReviewData() + var + DataUpgradeOverview: Page "Data Upgrade Overview"; + begin + Commit(); + Clear(DataUpgradeOverview); + DataUpgradeOverview.Set(TempDocumentEntry); + DataUpgradeOverview.RunModal(); + end; + + procedure AfterUpdate(FeatureDataUpdateStatus: Record "Feature Data Update Status") + var + UpdateFeatureDataUpdateStatus: Record "Feature Data Update Status"; + begin + UpdateFeatureDataUpdateStatus.SetRange("Feature Key", FeatureDataUpdateStatus."Feature Key"); + UpdateFeatureDataUpdateStatus.SetFilter("Company Name", '<>%1', FeatureDataUpdateStatus."Company Name"); + UpdateFeatureDataUpdateStatus.ModifyAll("Feature Status", FeatureDataUpdateStatus."Feature Status"); + SetUpgradeTag(true); + end; + + procedure UpdateData(FeatureDataUpdateStatus: Record "Feature Data Update Status") + var + FeatureDataUpdateMgt: Codeunit "Feature Data Update Mgt."; + StartDateTime: DateTime; + EndDateTime: DateTime; + begin + StartDateTime := CurrentDateTime; + FeatureDataUpdateMgt.LogTask(FeatureDataUpdateStatus, 'Upgrade Depreciation Differences FI', StartDateTime); + TransferFields(Database::"FA Posting Group", 13462, 13400); + TransferFields(Database::"FA Posting Group", 13463, 13401); + TransferFields(Database::"FA Ledger Entry", 13464, 13400); + TransferFields(Database::"Source Code Setup", 13465, 13400); + EndDateTime := CurrentDateTime; + FeatureDataUpdateMgt.LogTask(FeatureDataUpdateStatus, 'Upgrade Depreciation Differences FI', EndDateTime); + end; + + procedure GetTaskDescription() TaskDescription: Text + begin + TaskDescription := DescriptionTxt; + end; + + local procedure CountRecords() + begin + TempDocumentEntry.Reset(); + TempDocumentEntry.DeleteAll(); + InsertDocumentEntry(Database::"FA Posting Group", 'FA Posting Group', CountWithNonDefaultField(Database::"FA Posting Group", 13400, false) + CountWithNonDefaultField(Database::"FA Posting Group", 13401, false)); + InsertDocumentEntry(Database::"FA Ledger Entry", 'FA Ledger Entry', CountWithNonDefaultField(Database::"FA Ledger Entry", 13400, true)); + InsertDocumentEntry(Database::"Source Code Setup", 'Source Code Setup', CountWithNonDefaultField(Database::"Source Code Setup", 13400, false)); + end; + + local procedure CountWithNonDefaultField(TableId: Integer; SourceFieldNo: Integer; BooleanField: Boolean): Integer + var + RecRef: RecordRef; + SourceFieldRef: FieldRef; + begin + RecRef.Open(TableId, false); + SourceFieldRef := RecRef.Field(SourceFieldNo); + if BooleanField then + SourceFieldRef.SetFilter('%1', true) + else + SourceFieldRef.SetFilter('<>%1', ''); + exit(RecRef.Count()); + end; + + local procedure InsertDocumentEntry(TableID: Integer; TableName: Text; RecordCount: Integer) + begin + if RecordCount = 0 then + exit; + TempDocumentEntry.Init(); + TempDocumentEntry."Entry No." += 1; + TempDocumentEntry."Table ID" := TableID; + TempDocumentEntry."Table Name" := CopyStr(TableName, 1, MaxStrLen(TempDocumentEntry."Table Name")); + TempDocumentEntry."No. of Records" := RecordCount; + TempDocumentEntry.Insert(); + end; + + local procedure TransferFields(TableId: Integer; TargetFieldNo: Integer; SourceFieldNo: Integer) + var + RecRef: RecordRef; + TargetFieldRef: FieldRef; + SourceFieldRef: FieldRef; + begin + RecRef.Open(TableId, false); + SourceFieldRef := RecRef.Field(SourceFieldNo); + if RecRef.FindSet() then + repeat + TargetFieldRef := RecRef.Field(TargetFieldNo); + TargetFieldRef.Value := SourceFieldRef.Value; + RecRef.Modify(false); + until RecRef.Next() = 0; + end; + + local procedure SetUpgradeTag(DataUpgradeExecuted: Boolean) + var + UpgradeTag: Codeunit "Upgrade Tag"; + DepreciationDifferencesFIUpgradeTag: Codeunit "Dep Diff FI Upgrade Tag"; + begin + if UpgradeTag.HasUpgradeTag(DepreciationDifferencesFIUpgradeTag.GetUpgradeTag()) then + exit; + UpgradeTag.SetUpgradeTag(DepreciationDifferencesFIUpgradeTag.GetUpgradeTag()); + if not DataUpgradeExecuted then + UpgradeTag.SetSkippedUpgrade(DepreciationDifferencesFIUpgradeTag.GetUpgradeTag(), true); + end; +} +#endif diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepDiffFIUpgradeTag.Codeunit.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepDiffFIUpgradeTag.Codeunit.al new file mode 100644 index 00000000000..eb6a6c9c3e4 --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepDiffFIUpgradeTag.Codeunit.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// 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 System.Upgrade; + +codeunit 13476 "Dep Diff FI Upgrade Tag" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Upgrade Tag", OnGetPerCompanyUpgradeTags, '', false, false)] + local procedure OnGetPerCompanyUpgradeTags(var PerCompanyUpgradeTags: List of [Code[250]]) + begin + PerCompanyUpgradeTags.Add(GetUpgradeTag()); + end; + + procedure GetUpgradeTag(): Code[250] + begin + exit('MS-DepreciationDifferencesFIUpgradeTag-20260711'); + end; +} diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepreciationDifferencesFIFeature.Codeunit.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepreciationDifferencesFIFeature.Codeunit.al new file mode 100644 index 00000000000..5a9316b02f5 --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepreciationDifferencesFIFeature.Codeunit.al @@ -0,0 +1,38 @@ +#if not CLEAN29 +// ------------------------------------------------------------------------------------------------ +// 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 System.Environment.Configuration; + +codeunit 13466 "Depreciation Differences FI Feature" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + var + FeatureKeyIdTok: Label 'DepreciationDifferencesFI', Locked = true; + + procedure IsEnabled() Enabled: Boolean + var + FeatureManagementFacade: Codeunit "Feature Management Facade"; + begin + Enabled := FeatureManagementFacade.IsEnabled(FeatureKeyIdTok); + OnAfterCheckFeatureEnabled(Enabled); + end; + + procedure GetFeatureKeyId(): Text + begin + exit(FeatureKeyIdTok); + end; + + [IntegrationEvent(true, false)] + local procedure OnAfterCheckFeatureEnabled(var IsEnabled: Boolean) + begin + end; +} +#endif diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepreciationDifferencesFISubscribers.Codeunit.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepreciationDifferencesFISubscribers.Codeunit.al new file mode 100644 index 00000000000..0cc932614ee --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/DepreciationDifferencesFISubscribers.Codeunit.al @@ -0,0 +1,30 @@ +// ------------------------------------------------------------------------------------------------ +// 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.Foundation.Reporting; + +codeunit 13467 "Depreciation Differences FI Subscribers" +{ + Access = Internal; + InherentEntitlements = X; + InherentPermissions = X; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::ReportManagement, 'OnAfterSubstituteReport', '', false, false)] + local procedure OnAfterSubstituteReport(ReportId: Integer; var NewReportId: Integer) +#if not CLEAN29 + var + FeatureCU: Codeunit "Depreciation Differences FI Feature"; +#endif + begin +#if not CLEAN29 + if not FeatureCU.IsEnabled() then + exit; +#endif + if ReportId = 13402 then + NewReportId := Report::"Calc. and Post Depr. Diff."; + end; +} diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/UpgradeDepreciationDifferencesFI.Codeunit.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/UpgradeDepreciationDifferencesFI.Codeunit.al new file mode 100644 index 00000000000..2442ba6de44 --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/Codeunits/UpgradeDepreciationDifferencesFI.Codeunit.al @@ -0,0 +1,62 @@ +#if CLEAN29 +// ------------------------------------------------------------------------------------------------ +// 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 System.Upgrade; + +codeunit 13475 "Upgrade Depreciation Diff. FI" +{ + Access = Internal; + Subtype = Upgrade; + InherentEntitlements = X; + InherentPermissions = X; + + var + UpgradeTag: Codeunit "Upgrade Tag"; + DepreciationDifferencesFIUpgradeTag: Codeunit "Dep Diff FI Upgrade Tag"; + + trigger OnUpgradePerCompany() + var + CurrentModuleInfo: ModuleInfo; + begin + NavApp.GetCurrentModuleInfo(CurrentModuleInfo); + if CurrentModuleInfo.AppVersion().Major() < 32 then + exit; + + UpgradeDepreciationDifferencesFI(); + end; + + local procedure UpgradeDepreciationDifferencesFI() + begin + if UpgradeTag.HasUpgradeTag(DepreciationDifferencesFIUpgradeTag.GetUpgradeTag()) then + exit; + + TransferFields(Database::"FA Posting Group", 13462, 13400); + TransferFields(Database::"FA Posting Group", 13463, 13401); + TransferFields(Database::"FA Ledger Entry", 13464, 13400); + TransferFields(Database::"Source Code Setup", 13465, 13400); + + UpgradeTag.SetUpgradeTag(DepreciationDifferencesFIUpgradeTag.GetUpgradeTag()); + end; + + local procedure TransferFields(TableId: Integer; TargetFieldNo: Integer; SourceFieldNo: Integer) + var + RecRef: RecordRef; + TargetFieldRef: FieldRef; + SourceFieldRef: FieldRef; + begin + RecRef.Open(TableId, false); + SourceFieldRef := RecRef.Field(SourceFieldNo); + if RecRef.FindSet() then + repeat + TargetFieldRef := RecRef.Field(TargetFieldNo); + TargetFieldRef.Value := SourceFieldRef.Value; + RecRef.Modify(false); + until RecRef.Next() = 0; + end; +} +#endif diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/EnumExtensions/FeatureToUpdate.EnumExt.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/EnumExtensions/FeatureToUpdate.EnumExt.al new file mode 100644 index 00000000000..ff1af2234ee --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/EnumExtensions/FeatureToUpdate.EnumExt.al @@ -0,0 +1,21 @@ +#if not CLEAN29 +// ------------------------------------------------------------------------------------------------ +// 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 System.Environment.Configuration; + +enumextension 13474 "Depr Diff FI Feature To Update" extends "Feature To Update" +{ + value(13474; DepreciationDifferencesFI) + { + Implementation = "Feature Data Update" = "Dep Diff FI Feature Data Update"; + ObsoleteState = Pending; + ObsoleteReason = 'Feature Depreciation Differences FI will be enabled by default in version 32.0.'; + ObsoleteTag = '29.0'; + } +} +#endif diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FAPostingGroupCard.PageExt.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FAPostingGroupCard.PageExt.al new file mode 100644 index 00000000000..7be27eb3b3d --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FAPostingGroupCard.PageExt.al @@ -0,0 +1,29 @@ +// ------------------------------------------------------------------------------------------------ +// 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.FixedAsset; + +pageextension 13472 "FA Posting Group Card DeprDiff" extends "FA Posting Group Card" +{ + layout + { + addafter("Maintenance Expense Account") + { + field("Depreciation Difference Account"; Rec."Depreciation Difference Account") + { + ApplicationArea = FixedAssets; + ToolTip = 'Specifies the depreciation difference account that is associated with the fixed asset.'; + } + } + addafter("Maintenance Bal. Acc.") + { + field("Depreciation Difference Bal Acct"; Rec."Depreciation Difference Bal Acct") + { + ApplicationArea = FixedAssets; + ToolTip = 'Specifies the depreciation difference balance account that is associated with the fixed asset.'; + } + } + } +} diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FAPostingGroups.PageExt.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FAPostingGroups.PageExt.al new file mode 100644 index 00000000000..dce6156b475 --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FAPostingGroups.PageExt.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// 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.FixedAsset; + +pageextension 13473 "FA Posting Groups DeprDiff FI" extends "FA Posting Groups" +{ + layout + { + addafter("Custom 2 Account") + { + field("Depreciation Difference Account"; Rec."Depreciation Difference Account") + { + ApplicationArea = FixedAssets; + ToolTip = 'Specifies the depreciation difference account that is associated with the fixed asset.'; + } + field("Depreciation Difference Bal Acct"; Rec."Depreciation Difference Bal Acct") + { + ApplicationArea = FixedAssets; + ToolTip = 'Specifies the depreciation difference balance account that is associated with the fixed asset.'; + } + } + } +} diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FinanceManagerRC.PageExt.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FinanceManagerRC.PageExt.al new file mode 100644 index 00000000000..d11525d0c9c --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/FinanceManagerRC.PageExt.al @@ -0,0 +1,25 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace Microsoft.Finance.RoleCenters; + +using Microsoft.FixedAssets.Depreciation; + +pageextension 13480 "Finance Manager RC DeprDiff FI" extends "Finance Manager Role Center" +{ + actions + { + addafter("Insurance...") + { + action("Calc. and Post Depr. Difference") + { + ApplicationArea = Basic, Suite; + Caption = 'Calc. and Post Depr. Difference'; + RunObject = report "Calc. and Post Depr. Diff."; + ToolTip = 'Calculate and post the difference in accumulated depreciation between two depreciation books for each fixed asset.'; + } + } + } +} diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/SourceCodeSetup.PageExt.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/SourceCodeSetup.PageExt.al new file mode 100644 index 00000000000..4d6403d0d52 --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/PageExtensions/SourceCodeSetup.PageExt.al @@ -0,0 +1,21 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace Microsoft.Foundation.AuditCodes; + +pageextension 13479 "Source Code Setup DeprDiff Pg" extends "Source Code Setup" +{ + layout + { + addafter("Insurance Journal") + { + field("Depreciation Difference Code"; Rec."Depreciation Difference Code") + { + ApplicationArea = Basic, Suite; + ToolTip = 'Specifies the source code for posting differences in accumulated depreciation.'; + } + } + } +} diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/Reports/CalcAndPostDeprDiff.Report.al b/src/Apps/FI/DepreciationDifferencesFI/app/src/Reports/CalcAndPostDeprDiff.Report.al new file mode 100644 index 00000000000..cc4ff03e1ef --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/Reports/CalcAndPostDeprDiff.Report.al @@ -0,0 +1,381 @@ +// ------------------------------------------------------------------------------------------------ +// 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.Dimension; +using Microsoft.Finance.GeneralLedger.Journal; +using Microsoft.Finance.GeneralLedger.Posting; +using Microsoft.FixedAssets.FixedAsset; +using Microsoft.FixedAssets.Journal; +using Microsoft.FixedAssets.Ledger; +using Microsoft.Foundation.AuditCodes; + +report 13478 "Calc. and Post Depr. Diff." +{ + DefaultLayout = RDLC; + RDLCLayout = './src/Reports/CalcandPostDeprDiff.rdlc'; + ApplicationArea = Basic, Suite; + Caption = 'Calculate and Post Deprication Difference'; + Permissions = TableData "FA Ledger Entry" = rimd; + UsageCategory = ReportsAndAnalysis; + + dataset + { + dataitem(FixedAsset; "Fixed Asset") + { + RequestFilterFields = "No.", "FA Class Code", "FA Subclass Code", "FA Posting Group"; + column(CompanyName; COMPANYPROPERTY.DisplayName()) + { + } + column(FixedAssetFAFilter; FixedAsset.TableCaption + ': ' + FAFilter) + { + } + column(DeprBookAmt2; DeprBookAmt2) + { + } + column(DeprBookAmt1; DeprBookAmt1) + { + } + column(No_FixedAsset; "No.") + { + } + column(Description_FixedAsset; Description) + { + } + column(DifferenceAmt; DifferenceAmt) + { + } + column(FAPostingGroupCode; FAPostingGroup.Code) + { + } + column(DepreciationDifferenceEntriesCaption; DepreciationDifferenceEntriesCaptionLbl) + { + } + column(PageCaption; PageCaptionLbl) + { + } + column(DeprAmtforBookCode1Caption; DeprAmtForBookCode1CaptionLbl) + { + } + column(DeprAmtforBookCode2Caption; DeprAmtForBookCode2CaptionLbl) + { + } + column(No_FixedAssetCaption; FieldCaption("No.")) + { + } + column(Description_FixedAssetCaption; FieldCaption(Description)) + { + } + column(DeprDiffAmountCaption; DeprDiffAmountCaptionLbl) + { + } + column(FAPostingGroupCaption; FAPostingGroupCaptionLbl) + { + } + column(GroupTotalCaption; GroupTotalCaptionLbl) + { + } + column(TotalCaption; TotalCaptionLbl) + { + } + column(FAPostingGroup_FixedAsset; "FA Posting Group") + { + } + + trigger OnAfterGetRecord() + begin + DeprBookAmt1 := 0; + DeprBookAmt2 := 0; + DifferenceAmt := 0; + + if not (FADeprBook1.Get("No.", DeprBookCode1) and FADeprBook2.Get("No.", DeprBookCode2)) then + CurrReport.Skip(); + + TestField("FA Posting Group", FADeprBook1."FA Posting Group"); + if FADeprBook2."FA Posting Group" <> '' then + FADeprBook2.TestField("FA Posting Group", FADeprBook1."FA Posting Group"); + + if FAPostingGroup.Get(FADeprBook1."FA Posting Group") then begin + if FAPostingGroup."Depreciation Difference Account" = '' then + Error(Text13406, FAPostingGroup.Code); + if FAPostingGroup."Depreciation Difference Bal Acct" = '' then + Error(Text13407, FAPostingGroup.Code); + + FALedgerEntry.Reset(); + FALedgerEntry.SetCurrentKey("FA No.", "FA Posting Group", "Depreciation Book Code", + "FA Posting Category", "FA Posting Type", "Posting Date", "Depreciation Difference Posted"); + FALedgerEntry.SetRange("FA No.", "No."); + FALedgerEntry.SetRange("Depreciation Book Code", DeprBookCode1); + FALedgerEntry.SetFilter("FA Posting Category", '<>%1', FALedgerEntry."FA Posting Category"::Disposal); + FALedgerEntry.SetRange("FA Posting Type", FALedgerEntry."FA Posting Type"::Depreciation); + FALedgerEntry.SetRange("Posting Date", StartDate, EndDate); + FALedgerEntry.SetRange("Depreciation Difference Posted", false); + FALedgerEntry.CalcSums(Amount); + DeprBookAmt1 := FALedgerEntry.Amount; + + if PostDeprDiff then + FALedgerEntry.ModifyAll("Depreciation Difference Posted", true); + + FALedgerEntry.Reset(); + FALedgerEntry.SetCurrentKey("FA No.", "FA Posting Group", "Depreciation Book Code", + "FA Posting Category", "FA Posting Type", "Posting Date", "Depreciation Difference Posted"); + FALedgerEntry.SetRange("FA No.", "No."); + FALedgerEntry.SetRange("Depreciation Book Code", DeprBookCode2); + FALedgerEntry.SetFilter("FA Posting Category", '<>%1', FALedgerEntry."FA Posting Category"::Disposal); + FALedgerEntry.SetRange("FA Posting Type", FALedgerEntry."FA Posting Type"::Depreciation); + FALedgerEntry.SetRange("Posting Date", StartDate, EndDate); + FALedgerEntry.SetRange("Depreciation Difference Posted", false); + FALedgerEntry.CalcSums(Amount); + DeprBookAmt2 := FALedgerEntry.Amount; + + if PostDeprDiff then + FALedgerEntry.ModifyAll("Depreciation Difference Posted", true); + + DifferenceAmt := CalcDeprDifference(DeprBookAmt1, DeprBookAmt2); + + if ((DeprBookAmt1 <> 0) or (DeprBookAmt2 <> 0)) and (PrintEmptyLines or (DifferenceAmt <> 0)) then + InsertDifferenceBuffer() + else + CurrReport.Skip(); + end; + end; + + trigger OnPostDataItem() + begin + if PostDeprDiff then begin + DeprDiffPostingBuffer.Reset(); + if DeprDiffPostingBuffer.FindSet() then begin + repeat + PostJournalLines(DeprDiffPostingBuffer); + until DeprDiffPostingBuffer.Next() = 0; + Message(Text13408); + end else + Message(Text13412); + end; + + DeprDiffPostingBuffer.DeleteAll(); + end; + + trigger OnPreDataItem() + begin + FixedAsset.SetCurrentKey("FA Posting Group"); + + if PostDeprDiff then + if not Confirm(Text13409, false) then + CurrReport.Quit(); + end; + } + } + + requestpage + { + + layout + { + area(content) + { + group(Options) + { + Caption = 'Options'; + field("Depreciation Book Code 1"; DeprBookCode1) + { + ApplicationArea = Basic, Suite; + Caption = 'Depreciation Book Code 1'; + TableRelation = "Depreciation Book"; + ToolTip = 'Specifies the depreciation book that should be integrated with the general ledger.'; + } + field("Depreciation Book Code 2"; DeprBookCode2) + { + ApplicationArea = Basic, Suite; + Caption = 'Depreciation Book Code 2'; + TableRelation = "Depreciation Book"; + ToolTip = 'Specifies the depreciation book that should not be integrated with the general ledger.'; + } + field("Starting Date"; StartDate) + { + ApplicationArea = Basic, Suite; + Caption = 'Starting Date'; + ToolTip = 'Specifies the start for the depreciation difference calculation.'; + } + field("Ending Date"; EndDate) + { + ApplicationArea = Basic, Suite; + Caption = 'Ending Date'; + ToolTip = 'Specifies the end date for the depreciation difference calculation.'; + } + field("Posting Date"; PostingDate) + { + ApplicationArea = Basic, Suite; + Caption = 'Posting Date'; + ToolTip = 'Specifies the posting date to define when the depreciation difference calculation is applied.'; + } + field("Document No."; DocNo) + { + ApplicationArea = Basic, Suite; + Caption = 'Document No.'; + ToolTip = 'Specifies the document number.'; + } + field("Posting Description"; PostingDesc) + { + ApplicationArea = Basic, Suite; + Caption = 'Posting Description'; + ToolTip = 'Specifies a posting description.'; + } + field("Print Empty Lines"; PrintEmptyLines) + { + ApplicationArea = Basic, Suite; + Caption = 'Print Empty Lines'; + ToolTip = 'Specifies whether to print fixed asset lines that have no depreciation difference.'; + } + field("Post Depreciation Difference"; PostDeprDiff) + { + ApplicationArea = Basic, Suite; + Caption = 'Post'; + ToolTip = 'Specifies whether to post the depreciation difference.'; + } + } + } + } + + actions + { + } + } + + labels + { + } + + trigger OnPreReport() + begin + if (DeprBookCode1 = '') or (DeprBookCode2 = '') then + Error(Text13405); + if StartDate = 0D then + Error(Text13402); + if EndDate = 0D then + Error(Text13403); + if EndDate < StartDate then + Error(Text13404); + + if DeprBook.Get(DeprBookCode1) then + if not (DeprBook."G/L Integration - Depreciation" and DeprBook."G/L Integration - Acq. Cost") then + Error(Text13410); + + if DeprBook.Get(DeprBookCode2) then + if (DeprBook."G/L Integration - Depreciation") or (DeprBook."G/L Integration - Acq. Cost") then + Error(Text13411); + + if PostDeprDiff then begin + if PostingDate = 0D then + Error(Text13400); + if DocNo = '' then + Error(Text13401); + end; + + DeprBook.Get(DeprBookCode1); + FAGenReport.SetFAPostingGroup(FixedAsset, DeprBook.Code); + FAGenReport.AppendFAPostingFilter(FixedAsset, StartDate, EndDate); + FAFilter := FixedAsset.GetFilters(); + end; + + var + SourceCodeSetup: Record "Source Code Setup"; + FAPostingGroup: Record "FA Posting Group"; + DeprDiffPostingBuffer: Record "Depr. Diff. Posting Buffer" temporary; + GenJnlLine: Record "Gen. Journal Line"; + FALedgerEntry: Record "FA Ledger Entry"; + FADeprBook1: Record "FA Depreciation Book"; + FADeprBook2: Record "FA Depreciation Book"; + DeprBook: Record "Depreciation Book"; + FAJnlSetup: Record "FA Journal Setup"; + GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; + FAGenReport: Codeunit "FA General Report"; + DeprBookCode1: Code[20]; + DeprBookCode2: Code[20]; + DocNo: Code[20]; + PostingDesc: Text[50]; + FAFilter: Text[250]; + DifferenceAmt: Decimal; + DeprBookAmt1: Decimal; + DeprBookAmt2: Decimal; + GenJnlNextLineNo: Integer; + PostDeprDiff: Boolean; + PrintEmptyLines: Boolean; + Text13400: Label 'Please enter the Posting Date.'; + Text13401: Label 'Please enter the Document No.'; + Text13402: Label 'Please enter the Starting Date for Depreciation Calculation.'; + Text13403: Label 'Please enter the Ending Date for Depreciation Calculation.'; + Text13404: Label 'Ending Date must not be before Starting Date.'; + Text13405: Label 'Please specify Depreciation Book Code 1 and Depreciation Book Code 2.'; + Text13406: Label 'You must specify Depr. Difference Acc. in FA posting Group %1.'; + Text13407: Label 'You must specify Depr. Difference Bal. Acc. in FA posting Group %1.'; + Text13408: Label 'The Depreciation Difference was successfully posted.'; + Text13409: Label 'Do you want to post the Depreciation Difference ?'; + Text13410: Label 'The Depreciation Book Code 1 must be integrated with G/L.'; + Text13411: Label 'The Depreciation Book Code 2 must not be integrated with G/L.'; + Text13412: Label 'There is no Depreciation Difference posted for the specified period.'; + StartDate: Date; + EndDate: Date; + PostingDate: Date; + DepreciationDifferenceEntriesCaptionLbl: Label 'Depreciation Difference Entries'; + PageCaptionLbl: Label 'Page'; + DeprAmtForBookCode1CaptionLbl: Label 'Depr. Amt. for Book Code 1'; + DeprAmtForBookCode2CaptionLbl: Label 'Depr. Amt. for Book Code 2'; + DeprDiffAmountCaptionLbl: Label 'Depr. Diff. Amount'; + FAPostingGroupCaptionLbl: Label 'FA Posting Group'; + GroupTotalCaptionLbl: Label 'Group Total'; + TotalCaptionLbl: Label 'Total'; + + local procedure PostJournalLines(DeprDiffBuffer: Record "Depr. Diff. Posting Buffer") + var + DimMgt: Codeunit DimensionManagement; + DefaultDimSource: List of [Dictionary of [Integer, Code[20]]]; + begin + SourceCodeSetup.Get(); + Clear(GenJnlLine); + GenJnlNextLineNo := 0; + FAJnlSetup.GenJnlName(DeprBook, GenJnlLine, GenJnlNextLineNo); + GenJnlLine."System-Created Entry" := true; + GenJnlLine."Account Type" := GenJnlLine."Account Type"::"G/L Account"; + GenJnlLine."Account No." := DeprDiffBuffer."Depr. Difference Acc."; + GenJnlLine."Posting Date" := PostingDate; + GenJnlLine."Document No." := DocNo; + GenJnlLine.Description := PostingDesc; + GenJnlLine.Amount := + CalcDeprDifference(DeprDiffBuffer."Depreciation Amount 1", + DeprDiffBuffer."Depreciation Amount 2"); + GenJnlLine."Source Code" := SourceCodeSetup."Depreciation Difference Code"; + GenJnlLine."Bal. Account Type" := GenJnlLine."Bal. Account Type"::"G/L Account"; + GenJnlLine."Bal. Account No." := DeprDiffBuffer."Depr. Difference Bal. Acc."; + GenJnlLine."Line No." := GenJnlNextLineNo + 10000; + DimMgt.AddDimSource(DefaultDimSource, Database::"Fixed Asset", DeprDiffBuffer."FA No."); + + GenJnlLine."Dimension Set ID" := + DimMgt.GetDefaultDimID( + DefaultDimSource, GenJnlLine."Source Code", + GenJnlLine."Shortcut Dimension 1 Code", GenJnlLine."Shortcut Dimension 2 Code", + 0, 0); + + GenJnlPostLine.Run(GenJnlLine); + end; + + local procedure CalcDeprDifference(DeprAmt1: Decimal; DeprAmt2: Decimal): Decimal + begin + exit(DeprAmt1 - DeprAmt2); + end; + + local procedure InsertDifferenceBuffer() + begin + Clear(DeprDiffPostingBuffer); + DeprDiffPostingBuffer."Depr. Difference Acc." := FAPostingGroup."Depreciation Difference Account"; + DeprDiffPostingBuffer."Depr. Difference Bal. Acc." := FAPostingGroup."Depreciation Difference Bal Acct"; + DeprDiffPostingBuffer."Depreciation Amount 1" := DeprBookAmt1; + DeprDiffPostingBuffer."Depreciation Amount 2" := DeprBookAmt2; + DeprDiffPostingBuffer."FA No." := FixedAsset."No."; + DeprDiffPostingBuffer.Insert(); + end; +} + diff --git a/src/Apps/FI/DepreciationDifferencesFI/app/src/Reports/CalcandPostDeprDiff.rdlc b/src/Apps/FI/DepreciationDifferencesFI/app/src/Reports/CalcandPostDeprDiff.rdlc new file mode 100644 index 00000000000..a0c52137674 --- /dev/null +++ b/src/Apps/FI/DepreciationDifferencesFI/app/src/Reports/CalcandPostDeprDiff.rdlc @@ -0,0 +1,1124 @@ + + + 0 + + + + SQL + + + None + 13a0cd68-6053-493a-b787-47db4086f58e + + + + + + + + + + + 0.88583in + + + 1.77165in + + + 0.59055in + + + 0.70866in + + + 0.70866in + + + 0.70866in + + + + + 0.33307in + + + + + true + true + + + + + =First(Fields!No_FixedAssetCaption.Value) + + + + + + + + + + + true + true + + + + + =First(Fields!Description_FixedAssetCaption.Value) + + + + + + + + + + + true + true + + + + + =First(Fields!FAPostingGroupCaption.Value) + + + + + + + + + + + + + + true + true + + + + + =First(Fields!DeprAmtforBookCode1Caption.Value) + + + + + + + + + + + + + + true + true + + + + + =First(Fields!DeprAmtforBookCode2Caption.Value) + + + + + + + + + + + + + + true + true + + + + + =First(Fields!DeprDiffAmountCaption.Value) + + + + + + + + + + + + + + 0.16654in + + + + + true + + + + + =Fields!No_FixedAsset.Value + + + + + + + + + + + + + + true + + + + + =Fields!Description_FixedAsset.Value + + + + + + + + + + + true + + + + + =Fields!FAPostingGroupCode.Value + + + + + + + + + + + + + + true + + + + + =Fields!DeprBookAmt1.Value + + + + + + + + + + + true + + + + + =Fields!DeprBookAmt2.Value + + + + + + + + + + + true + + + + + =Fields!DifferenceAmt.Value + + + + + + + + + + + 0.16654in + + + + + true + + + + + =First(Fields!GroupTotalCaption.Value) + + + + + + + + + + + true + + + + + + + + + + + + + true + + + + + + + + + + + + + true + + + + + =Sum(Fields!DeprBookAmt1.Value) + + + + + + + + + + + + + + true + + + + + =Sum(Fields!DeprBookAmt2.Value) + + + + + + + + + + + + + + true + + + + + =Sum(Fields!DifferenceAmt.Value) + + + + + + + + + + + + + + 0.16654in + + + + + true + + + + + =First(Fields!TotalCaption.Value) + + + + + + + + + + + true + + + + + + + + + + + + + true + + + + + + + + + + + + + true + + + + + =Sum(Fields!DeprBookAmt1.Value) + + + + + + + + + + + + + + true + + + + + =Sum(Fields!DeprBookAmt2.Value) + + + + + + + + + + + + + + true + + + + + =Sum(Fields!DifferenceAmt.Value) + + + + + + + + + + + + + + + + + + + + + + + + + + + + After + true + true + + + + + =Fields!FAPostingGroup_FixedAsset.Value + + + + + + Detail + + + + + Detail_Collection + Output + true + + + Before + true + + + + + Before + true + + + + DataSet_Result + 0.846cm + 2.115cm + 13.65cm + + + + + + + 2.961cm + + + + + + + true + + + + + =Fields!DepreciationDifferenceEntriesCaption.Value + + + + + + + true + + + + + =Fields!PageCaption.Value + + + + + + + true + + + + + =Globals!PageNumber + + + + + + + 0.423cm + 17.7cm + 0.423cm + 0.45cm + 3 + + + + true + true + + + + + =User!UserID + + + + + + + 0.846cm + 13.1cm + 0.423cm + 5.05cm + 4 + + + + true + + + + + =Globals!ExecutionTime + + + + + + + 0cm + 14.1cm + 0.423cm + 4.05cm + 5 + + + +