diff --git a/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/InstallApplicationCZL.Codeunit.al b/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/InstallApplicationCZL.Codeunit.al index 140e996e139..2c20820f9e4 100644 --- a/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/InstallApplicationCZL.Codeunit.al +++ b/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/InstallApplicationCZL.Codeunit.al @@ -54,8 +54,10 @@ using Microsoft.Service.Document; using Microsoft.Service.History; using Microsoft.Service.Reports; using Microsoft.Service.Setup; +using Microsoft.Upgrade; using Microsoft.Utilities; using System.IO; +using System.Reflection; using System.Security.Encryption; using System.Security.User; using System.Upgrade; @@ -598,6 +600,7 @@ codeunit 11748 "Install Application CZL" InitEETServiceSetup(); CreateSourceCodeSetup(); ModifyReportSelections(); + InitDefaultReportLayouts(); DataClassEvalHandlerCZL.ApplyEvaluationClassificationsForPrivacy(); UpgradeTag.SetAllUpgradeTags(); @@ -877,4 +880,17 @@ codeunit 11748 "Install Application CZL" ItemJournalTemplate.Modify(); until ItemJournalTemplate.Next() = 0; end; + + local procedure InitDefaultReportLayouts() + var + ReportLayoutList: Record "Report Layout List"; + UpgradeApplicationCZL: Codeunit "Upgrade Application CZL"; + begin + if UpgradeApplicationCZL.GetDraftInvoiceReportLayoutCZ(ReportLayoutList) then + if not UpgradeApplicationCZL.IsReportLayoutSelectionCustomized(Report::"Standard Sales - Draft Invoice") then + UpgradeApplicationCZL.SetDefaultReportLayout(ReportLayoutList); + if UpgradeApplicationCZL.GetProformaReportLayoutCZ(ReportLayoutList) then + if not UpgradeApplicationCZL.IsReportLayoutSelectionCustomized(Report::"Standard Sales - Pro Forma Inv") then + UpgradeApplicationCZL.SetDefaultReportLayout(ReportLayoutList); + end; } \ No newline at end of file diff --git a/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/UpgradeApplicationCZL.Codeunit.al b/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/UpgradeApplicationCZL.Codeunit.al index 551fbc7a352..ca188e812a4 100644 --- a/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/UpgradeApplicationCZL.Codeunit.al +++ b/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/UpgradeApplicationCZL.Codeunit.al @@ -46,6 +46,7 @@ using Microsoft.Service.Document; using Microsoft.Service.History; using Microsoft.Service.Setup; using System.Environment.Configuration; +using System.Reflection; using System.Security.AccessControl; using System.Security.Encryption; using System.Security.User; @@ -141,7 +142,9 @@ codeunit 31017 "Upgrade Application CZL" tabledata "Gen. Journal Template" = m, tabledata "VAT Entry" = m, tabledata "Report Selections" = m, - tabledata "G/L Entry" = m; + tabledata "G/L Entry" = m, + tabledata "Report Layout Selection" = im, + tabledata "Tenant Report Layout Selection" = im; var DataUpgradeMgt: Codeunit "Data Upgrade Mgt."; @@ -149,6 +152,8 @@ codeunit 31017 "Upgrade Application CZL" UpgradeTagDefinitionsCZL: Codeunit "Upgrade Tag Definitions CZL"; InstallApplicationsMgtCZL: Codeunit "Install Applications Mgt. CZL"; AppInfo: ModuleInfo; + DraftInvoiceReportLayoutNameTok: Label 'StdSalesDraftInvoice.rdl CZL', Locked = true; + ProformaReportLayoutNameTok: Label 'StdSalesProFormaInv.rdl CZL', Locked = true; trigger OnUpgradePerDatabase() begin @@ -187,6 +192,7 @@ codeunit 31017 "Upgrade Application CZL" UpgradeUseVATReturnPeriodInsteadOfVATPeriod(); #endif UpgradeOriginalVATAmountsACYInVATEntries(); + UpgradeDraftInvoiceAndProformaReportLayouts(); end; local procedure UpgradeReplaceVATDateCZL() @@ -846,6 +852,123 @@ codeunit 31017 "Upgrade Application CZL" end; #endif + local procedure UpgradeDraftInvoiceAndProformaReportLayouts() + var + ReportLayoutList: Record "Report Layout List"; + begin + if UpgradeTag.HasUpgradeTag(UpgradeTagDefinitionsCZL.GetChangeDefaultDraftInvoiceAndProformaReportLayoutsUpgradeTag()) then + exit; + + if GetDraftInvoiceReportLayoutCZ(ReportLayoutList) then + if not IsReportLayoutSelectionCustomized(Report::"Standard Sales - Draft Invoice") then + SetDefaultReportLayout(ReportLayoutList); + + if GetProformaReportLayoutCZ(ReportLayoutList) then + if not IsReportLayoutSelectionCustomized(Report::"Standard Sales - Pro Forma Inv") then + SetDefaultReportLayout(ReportLayoutList); + + UpgradeTag.SetUpgradeTag(UpgradeTagDefinitionsCZL.GetChangeDefaultDraftInvoiceAndProformaReportLayoutsUpgradeTag()); + end; + + internal procedure IsReportLayoutSelectionCustomized(ReportId: Integer): Boolean + var + DefaultMetadataReportLayoutName: Text[100]; + DefaultSelectionReportLayoutName: Text[250]; + begin + DefaultMetadataReportLayoutName := GetDefaultMetadataReportLayoutName(ReportId); + DefaultSelectionReportLayoutName := GetDefaultSelectionReportLayoutName(ReportId); + exit((DefaultSelectionReportLayoutName <> '') and (DefaultSelectionReportLayoutName <> DefaultMetadataReportLayoutName)); + end; + + local procedure GetDefaultMetadataReportLayoutName(ReportId: Integer): Text[100] + var + ReportMetadata: Record "Report Metadata"; + begin + if ReportMetadata.Get(ReportId) then + exit(ReportMetadata."DefaultLayoutName"); + exit(''); + end; + + local procedure GetDefaultSelectionReportLayoutName(ReportId: Integer): Text[250] + var + TenantReportLayoutSelection: Record "Tenant Report Layout Selection"; + EmptyGuid: Guid; + begin + if TenantReportLayoutSelection.Get(ReportId, CompanyName(), EmptyGuid) then + exit(TenantReportLayoutSelection."Layout Name"); + exit(''); + end; + + internal procedure GetDraftInvoiceReportLayoutCZ(var ReportLayoutList: Record "Report Layout List"): Boolean + begin + NavApp.GetCurrentModuleInfo(AppInfo); + ReportLayoutList.Reset(); + ReportLayoutList.SetRange("Report ID", Report::"Standard Sales - Draft Invoice"); + ReportLayoutList.SetRange("Name", DraftInvoiceReportLayoutNameTok); + ReportLayoutList.SetRange("Application ID", AppInfo.Id); + exit(ReportLayoutList.FindFirst()); + end; + + internal procedure GetProformaReportLayoutCZ(var ReportLayoutList: Record "Report Layout List"): Boolean + begin + NavApp.GetCurrentModuleInfo(AppInfo); + ReportLayoutList.Reset(); + ReportLayoutList.SetRange("Report ID", Report::"Standard Sales - Pro Forma Inv"); + ReportLayoutList.SetRange("Name", ProformaReportLayoutNameTok); + ReportLayoutList.SetRange("Application ID", AppInfo.Id); + exit(ReportLayoutList.FindFirst()); + end; + + internal procedure SetDefaultReportLayout(ReportLayoutList: Record "Report Layout List") + var + ReportLayoutSelection: Record "Report Layout Selection"; + begin + // Add to TenantReportLayoutSelection table with an Empty Guid. + AddLayoutSelection(ReportLayoutList); + + // Add to the report layout selection table + if ReportLayoutSelection.Get(ReportLayoutList."Report ID", CompanyName()) then begin + ReportLayoutSelection.Type := GetReportLayoutSelectionCorrespondingEnum(ReportLayoutList); + ReportLayoutSelection.Modify(false); + end else begin + ReportLayoutSelection."Report ID" := ReportLayoutList."Report ID"; + ReportLayoutSelection."Company Name" := CopyStr(CompanyName(), 1, MaxStrLen(ReportLayoutSelection."Company Name")); + ReportLayoutSelection."Custom Report Layout Code" := ''; + ReportLayoutSelection.Type := GetReportLayoutSelectionCorrespondingEnum(ReportLayoutList); + ReportLayoutSelection.Insert(false); + end; + end; + + local procedure AddLayoutSelection(ReportLayoutList: Record "Report Layout List"): Boolean + var + TenantReportLayoutSelection: Record "Tenant Report Layout Selection"; + EmptyGuid: Guid; + begin + TenantReportLayoutSelection.Init(); + TenantReportLayoutSelection."App ID" := ReportLayoutList."Application ID"; + TenantReportLayoutSelection."Company Name" := CopyStr(CompanyName(), 1, MaxStrLen(TenantReportLayoutSelection."Company Name")); + TenantReportLayoutSelection."Layout Name" := ReportLayoutList."Name"; + TenantReportLayoutSelection."Report ID" := ReportLayoutList."Report ID"; + TenantReportLayoutSelection."User ID" := EmptyGuid; + + if not TenantReportLayoutSelection.Insert(false) then + TenantReportLayoutSelection.Modify(false); + end; + + local procedure GetReportLayoutSelectionCorrespondingEnum(SelectedReportLayoutList: Record "Report Layout List"): Integer + begin + case SelectedReportLayoutList."Layout Format" of + SelectedReportLayoutList."Layout Format"::RDLC: + exit(0); + SelectedReportLayoutList."Layout Format"::Word: + exit(1); + SelectedReportLayoutList."Layout Format"::Excel: + exit(3); + SelectedReportLayoutList."Layout Format"::Custom: + exit(4); + end + end; + local procedure InsertRepSelection(ReportUsage: Enum "Report Selection Usage"; Sequence: Code[10]; ReportID: Integer) var diff --git a/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/UpgradeTagDefinitionsCZL.Codeunit.al b/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/UpgradeTagDefinitionsCZL.Codeunit.al index 08a5ef17945..b59dde57894 100644 --- a/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/UpgradeTagDefinitionsCZL.Codeunit.al +++ b/src/Apps/CZ/CoreLocalizationPack/app/Src/Codeunits/UpgradeTagDefinitionsCZL.Codeunit.al @@ -50,6 +50,7 @@ codeunit 31016 "Upgrade Tag Definitions CZL" PerCompanyUpgradeTags.Add(GetUseW1RegistrationNumberFromSalesDocUpgradeTag()); PerCompanyUpgradeTags.Add(GetUseVATReturnPeriodInsteadOfVATPeriodUpgradeTag()); PerCompanyUpgradeTags.Add(GetOriginalVATAmountsACYInVATEntriesUpgradeTag()); + PerCompanyUpgradeTags.Add(GetChangeDefaultDraftInvoiceAndProformaReportLayoutsUpgradeTag()); end; procedure GetDataVersion174PerDatabaseUpgradeTag(): Code[250] @@ -223,4 +224,9 @@ codeunit 31016 "Upgrade Tag Definitions CZL" begin exit('CZL-616614-OriginalVATAmountsACYInVATEntriesTag-20251217'); end; + + procedure GetChangeDefaultDraftInvoiceAndProformaReportLayoutsUpgradeTag(): Code[250] + begin + exit('CZL-640925-ChangeDefaultDraftInvoiceAndProformaReportLayoutsUpgradeTag-20260908'); + end; } diff --git a/src/Apps/CZ/CoreLocalizationPack/app/Src/ReportExtensions/StdSalesProFormaInv.rdl b/src/Apps/CZ/CoreLocalizationPack/app/Src/ReportExtensions/StdSalesProFormaInv.rdl index a678d1def30..deadb3723fb 100644 --- a/src/Apps/CZ/CoreLocalizationPack/app/Src/ReportExtensions/StdSalesProFormaInv.rdl +++ b/src/Apps/CZ/CoreLocalizationPack/app/Src/ReportExtensions/StdSalesProFormaInv.rdl @@ -2646,16 +2646,13 @@ Cstr(Fields!PageLbl.Value) - 1.73536cm + 4.41919cm - 3.44564cm + 1.49243cm - 1.27273cm - - - 1.6364cm + 1.78163cm 1.63715cm @@ -2667,7 +2664,7 @@ Cstr(Fields!PageLbl.Value) 2.45453cm - 1.45454cm + 1.85142cm 0.95454cm @@ -2680,47 +2677,6 @@ Cstr(Fields!PageLbl.Value) 0.17717in - - - - true - true - - - - - =Fields!ItemNoCaption_CZL.Value - - - - - - - - 0.5pt - - - - - - - - Bottom - 2pt - 2pt - 2pt - 2pt - - - - @@ -3091,14 +3047,14 @@ Cstr(Fields!PageLbl.Value) - + true true - + =Fields!ItemDescription.Value @@ -3107,7 +3063,7 @@ Cstr(Fields!PageLbl.Value) + 9 + + + + + + + + + + + + 0.17717in + - + true true @@ -3139,7 +3109,7 @@ Cstr(Fields!PageLbl.Value) - 9 - - - - - - - - - - - - 0.17717in - - + true true - =IIf(Fields!Type_Line_CZL.Value = "0", "", Fields!ItemNo_Line_CZL.Value) + =Fields!CountryOfManufacturing.Value @@ -3185,7 +3141,6 @@ Cstr(Fields!PageLbl.Value) - - Description_SalesInvoiceLine + + + + + + Quantity_SalesInvoiceLine + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!UnitOfMeasure_CZL.Value @@ -3249,6 +3239,7 @@ Cstr(Fields!PageLbl.Value) @@ -3282,6 +3273,7 @@ Cstr(Fields!PageLbl.Value) + UnitPrice_SalesInvoiceLine @@ -3315,7 +3307,6 @@ Cstr(Fields!PageLbl.Value) - Quantity_SalesInvoiceLine - - Textbox1 + VAT_SalesInvoiceLine @@ -3381,7 +3374,7 @@ Cstr(Fields!PageLbl.Value) - UnitPrice_SalesInvoiceLine + Amount_SalesInvoiceLine - + - + - + - 5 - - - - @@ -3624,7 +3610,7 @@ Cstr(Fields!PageLbl.Value) - + true true @@ -3641,7 +3627,106 @@ Cstr(Fields!PageLbl.Value) + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + - 5 - - - - @@ -3746,7 +3826,7 @@ Cstr(Fields!PageLbl.Value) - + true true @@ -3762,7 +3842,103 @@ Cstr(Fields!PageLbl.Value) + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + - 5 - - - - @@ -3857,7 +4028,7 @@ Cstr(Fields!PageLbl.Value) - + true true @@ -3874,7 +4045,106 @@ Cstr(Fields!PageLbl.Value) + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + + + + + - 5 - - - - @@ -3987,7 +4252,6 @@ Cstr(Fields!PageLbl.Value) - @@ -4592,7 +4856,7 @@ Cstr(Fields!PageLbl.Value) - =StrConv(Fields!TotalAmountInclVATLbl.Value, VbStrConv.ProperCase) + =StrConv(Fields!TotalLbl_CZL.Value, VbStrConv.ProperCase)