diff --git a/src/Layers/NA/BaseApp/Finance/GeneralLedger/Account/GLAccountCard.Page.al b/src/Layers/NA/BaseApp/Finance/GeneralLedger/Account/GLAccountCard.Page.al index e1a4bf03f00..4ed8a72a644 100644 --- a/src/Layers/NA/BaseApp/Finance/GeneralLedger/Account/GLAccountCard.Page.al +++ b/src/Layers/NA/BaseApp/Finance/GeneralLedger/Account/GLAccountCard.Page.al @@ -215,11 +215,13 @@ page 17 "G/L Account Card" { ApplicationArea = Basic, Suite; Importance = Promoted; + Visible = VATInUse; } field("VAT Prod. Posting Group"; Rec."VAT Prod. Posting Group") { ApplicationArea = Basic, Suite; Importance = Promoted; + Visible = VATInUse; } field("Tax Group Code"; Rec."Tax Group Code") { @@ -734,6 +736,7 @@ page 17 "G/L Account Card" var ExtendedPriceEnabled: Boolean; + VATInUse: Boolean; SubCategoryDescription: Text[80]; local procedure UpdateAccountSubcategoryDescription() @@ -744,8 +747,11 @@ page 17 "G/L Account Card" local procedure SetControlVisibility() var + GLSetup: Record "General Ledger Setup"; PriceCalculationMgt: Codeunit "Price Calculation Mgt."; begin + GLSetup.Get(); + VATInUse := GLSetup."VAT in Use"; ExtendedPriceEnabled := PriceCalculationMgt.IsExtendedPriceCalculationEnabled(); end; } \ No newline at end of file diff --git a/src/Layers/NA/BaseApp/Inventory/Item/ItemTemplCard.Page.al b/src/Layers/NA/BaseApp/Inventory/Item/ItemTemplCard.Page.al index 4e76c227362..f3b2c9c7fcb 100644 --- a/src/Layers/NA/BaseApp/Inventory/Item/ItemTemplCard.Page.al +++ b/src/Layers/NA/BaseApp/Inventory/Item/ItemTemplCard.Page.al @@ -5,6 +5,7 @@ namespace Microsoft.Inventory.Item; using Microsoft.Finance.Dimension; +using Microsoft.Finance.GeneralLedger.Setup; using Microsoft.Inventory.Planning; using Microsoft.Inventory.Setup; @@ -209,6 +210,7 @@ page 1384 "Item Templ. Card" ApplicationArea = Basic, Suite; Importance = Additional; ShowMandatory = true; + Visible = VATInUse; } field("Tax Group Code"; Rec."Tax Group Code") { @@ -253,7 +255,7 @@ page 1384 "Item Templ. Card" } field("Price Includes VAT"; Rec."Price Includes VAT") { - ApplicationArea = Basic, Suite; + ApplicationArea = VAT; Importance = Additional; } field("Price/Profit Calculation"; Rec."Price/Profit Calculation") @@ -593,13 +595,18 @@ page 1384 "Item Templ. Card" end; trigger OnOpenPage() + var + GLSetup: Record "General Ledger Setup"; begin + GLSetup.Get(); + VATInUse := GLSetup."VAT in Use"; EnablePlanningControls(); EnableShowVariantMandatory(); end; var ShowVariantMandatoryDefaultYes: Boolean; + VATInUse: Boolean; protected var TimeBucketEnable: Boolean; diff --git a/src/Layers/NA/BaseApp/Projects/Resources/Resource/ResourceCard.Page.al b/src/Layers/NA/BaseApp/Projects/Resources/Resource/ResourceCard.Page.al index 234e10ab9c5..b917466af20 100644 --- a/src/Layers/NA/BaseApp/Projects/Resources/Resource/ResourceCard.Page.al +++ b/src/Layers/NA/BaseApp/Projects/Resources/Resource/ResourceCard.Page.al @@ -5,6 +5,7 @@ namespace Microsoft.Projects.Resources.Resource; using Microsoft.Finance.Dimension; +using Microsoft.Finance.GeneralLedger.Setup; using Microsoft.Foundation.Address; using Microsoft.Foundation.Attachment; using Microsoft.Foundation.Comment; @@ -145,6 +146,7 @@ page 76 "Resource Card" { ApplicationArea = Basic, Suite; Importance = Promoted; + Visible = VATInUse; } field("Default Deferral Template Code"; Rec."Default Deferral Template Code") { @@ -739,8 +741,11 @@ page 76 "Resource Card" trigger OnOpenPage() var + GLSetup: Record "General Ledger Setup"; IntegrationTableMapping: Record "Integration Table Mapping"; begin + GLSetup.Get(); + VATInUse := GLSetup."VAT in Use"; CRMIntegrationEnabled := CRMIntegrationManagement.IsCRMIntegrationEnabled(); if IntegrationTableMapping.Get('RESOURCE-PRODUCT') then BlockedFilterApplied := IntegrationTableMapping.GetTableFilter().Contains('Field38=1(0)'); @@ -759,6 +764,7 @@ page 76 "Resource Card" ExtendedPriceEnabled: Boolean; NoFieldVisible: Boolean; IsCountyVisible: Boolean; + VATInUse: Boolean; local procedure SetNoFieldVisible() var diff --git a/src/Layers/NA/BaseApp/Purchases/Vendor/VendorTemplCard.Page.al b/src/Layers/NA/BaseApp/Purchases/Vendor/VendorTemplCard.Page.al index 701c1eae1ca..f9e025f3c46 100644 --- a/src/Layers/NA/BaseApp/Purchases/Vendor/VendorTemplCard.Page.al +++ b/src/Layers/NA/BaseApp/Purchases/Vendor/VendorTemplCard.Page.al @@ -5,6 +5,7 @@ namespace Microsoft.Purchases.Vendor; using Microsoft.Finance.Dimension; +using Microsoft.Finance.GeneralLedger.Setup; using Microsoft.Foundation.Address; page 1386 "Vendor Templ. Card" @@ -216,7 +217,7 @@ page 1386 "Vendor Templ. Card" } field("Prices Including VAT"; Rec."Prices Including VAT") { - ApplicationArea = Basic, Suite; + ApplicationArea = VAT; Importance = Additional; } field("Price Calculation Method"; Rec."Price Calculation Method") @@ -238,6 +239,7 @@ page 1386 "Vendor Templ. Card" { ApplicationArea = Basic, Suite; Importance = Additional; + Visible = VATInUse; } field("Vendor Posting Group"; Rec."Vendor Posting Group") { @@ -443,11 +445,16 @@ page 1386 "Vendor Templ. Card" } trigger OnOpenPage() + var + GLSetup: Record "General Ledger Setup"; begin + GLSetup.Get(); + VATInUse := GLSetup."VAT in Use"; IsCountyVisible := FormatAddress.UseCounty(Rec."Country/Region Code"); end; var FormatAddress: Codeunit "Format Address"; IsCountyVisible: Boolean; + VATInUse: Boolean; } \ No newline at end of file diff --git a/src/Layers/NA/BaseApp/Sales/Customer/CustomerTemplCard.Page.al b/src/Layers/NA/BaseApp/Sales/Customer/CustomerTemplCard.Page.al index 7d271c6fa79..5ccfc944a9b 100644 --- a/src/Layers/NA/BaseApp/Sales/Customer/CustomerTemplCard.Page.al +++ b/src/Layers/NA/BaseApp/Sales/Customer/CustomerTemplCard.Page.al @@ -5,6 +5,7 @@ namespace Microsoft.Sales.Customer; using Microsoft.Finance.Dimension; +using Microsoft.Finance.GeneralLedger.Setup; using Microsoft.Foundation.Address; using Microsoft.Pricing.Calculation; using Microsoft.Sales.Setup; @@ -268,6 +269,7 @@ page 1382 "Customer Templ. Card" { ApplicationArea = Basic, Suite; Importance = Additional; + Visible = VATInUse; } field("Customer Posting Group"; Rec."Customer Posting Group") { @@ -518,8 +520,11 @@ page 1382 "Customer Templ. Card" trigger OnOpenPage() var + GLSetup: Record "General Ledger Setup"; PriceCalculationMgt: Codeunit "Price Calculation Mgt."; begin + GLSetup.Get(); + VATInUse := GLSetup."VAT in Use"; IsCountyVisible := FormatAddress.UseCounty(Rec."Country/Region Code"); SalesReceivablesSetup.Get(); IsAllowMultiplePostingGroupsVisible := SalesReceivablesSetup."Allow Multiple Posting Groups"; @@ -532,4 +537,5 @@ page 1382 "Customer Templ. Card" ExtendedPriceEnabled: Boolean; IsAllowMultiplePostingGroupsVisible: Boolean; IsCountyVisible: Boolean; + VATInUse: Boolean; } diff --git a/src/Layers/NA/Tests/SMB/O365TemplatesTest.Codeunit.al b/src/Layers/NA/Tests/SMB/O365TemplatesTest.Codeunit.al index c2edb04bbf8..6ea01684979 100644 --- a/src/Layers/NA/Tests/SMB/O365TemplatesTest.Codeunit.al +++ b/src/Layers/NA/Tests/SMB/O365TemplatesTest.Codeunit.al @@ -12,6 +12,7 @@ codeunit 138012 "O365 Templates Test" LibraryInventory: Codeunit "Library - Inventory"; LibraryPurchase: Codeunit "Library - Purchase"; LibrarySales: Codeunit "Library - Sales"; + LibraryResource: Codeunit "Library - Resource"; LibraryRandom: Codeunit "Library - Random"; LibraryVariableStorage: Codeunit "Library - Variable Storage"; LibraryUtility: Codeunit "Library - Utility"; @@ -36,6 +37,7 @@ codeunit 138012 "O365 Templates Test" StartingNumberTxt: Label 'ABC00010D'; EndingNumberTxt: Label 'ABC00090D'; InsertedItemErr: Label 'Item inserted with wrong data'; + PageFieldNotFoundErr: Label 'The field with ID = %1 is not found on the page.', Locked = true, Comment = '%1 = page control ID'; [Test] [HandlerFunctions('CustomerTemplateCardHandler')] @@ -1602,6 +1604,230 @@ codeunit 138012 "O365 Templates Test" VerifyItemAfterApplyTemplateWithPhysInvtCountingPeriod(Item, ItemTempl); end; + [Test] + procedure ItemTemplateVATFieldsHiddenWhenVATNotInUse() + var + ItemTemplate: Record "Item Templ."; + ItemTemplateCard: TestPage "Item Templ. Card"; + begin + // [FEATURE] [AI test 1.0] + // [SCENARIO] Item templates hide VAT posting fields without hiding sales tax fields when VAT is not in use. + Initialize(); + + // [GIVEN] An item template with VAT in Use disabled while VAT and sales tax application areas are enabled. + SetVATInUse(false); + LibraryTemplates.CreateItemTemplateWithData(ItemTemplate); + + // [WHEN] The item template card is opened. + ItemTemplateCard.OpenView(); + ItemTemplateCard.GoToRecord(ItemTemplate); + + // [THEN] VAT posting fields are hidden and the sales tax field remains visible. + VerifyItemTemplateVATFieldVisibility(ItemTemplateCard, false); + ItemTemplateCard.Close(); + end; + + [Test] + procedure GLAccountVATFieldsHiddenWhenVATNotInUse() + var + GLAccount: Record "G/L Account"; + GLAccountCard: TestPage "G/L Account Card"; + begin + // [FEATURE] [AI test 1.0] + // [SCENARIO] G/L accounts hide VAT posting fields without hiding sales tax fields when VAT is not in use. + Initialize(); + + // [GIVEN] A G/L account with VAT in Use disabled while VAT and sales tax application areas are enabled. + SetVATInUse(false); + LibraryERM.CreateGLAccount(GLAccount); + + // [WHEN] The G/L account card is opened. + GLAccountCard.OpenView(); + GLAccountCard.GoToRecord(GLAccount); + + // [THEN] VAT posting fields are hidden and the sales tax field remains visible. + VerifyGLAccountVATFieldVisibility(GLAccountCard, false); + GLAccountCard.Close(); + end; + + [Test] + procedure CustomerTemplateVATPostingHiddenWhenVATNotInUse() + var + CustomerTemplate: Record "Customer Templ."; + CustomerTemplateCard: TestPage "Customer Templ. Card"; + begin + // [FEATURE] [AI test 1.0] + // [SCENARIO] Customer templates hide VAT posting setup without hiding general posting setup when VAT is not in use. + Initialize(); + + // [GIVEN] A customer template with VAT in Use disabled while the VAT application area is enabled. + SetVATInUse(false); + LibraryTemplates.CreateCustomerTemplate(CustomerTemplate); + + // [WHEN] The customer template card is opened. + CustomerTemplateCard.OpenView(); + CustomerTemplateCard.GoToRecord(CustomerTemplate); + + // [THEN] Only the VAT posting group is hidden. + Assert.IsFalse(CustomerTemplateCard."VAT Bus. Posting Group".Visible(), 'Customer template VAT posting group must be hidden when VAT is not in use.'); + Assert.IsTrue(CustomerTemplateCard."Gen. Bus. Posting Group".Visible(), 'Customer template general posting group must remain visible.'); + Assert.IsTrue(CustomerTemplateCard."Customer Posting Group".Visible(), 'Customer posting group must remain visible.'); + CustomerTemplateCard.Close(); + end; + + [Test] + procedure VendorTemplateVATPostingHiddenWhenVATNotInUse() + var + VendorTemplate: Record "Vendor Templ."; + VendorTemplateCard: TestPage "Vendor Templ. Card"; + begin + // [FEATURE] [AI test 1.0] + // [SCENARIO] Vendor templates hide VAT posting setup without hiding general posting setup when VAT is not in use. + Initialize(); + + // [GIVEN] A vendor template with VAT in Use disabled while the VAT application area is enabled. + SetVATInUse(false); + LibraryTemplates.CreateVendorTemplate(VendorTemplate); + + // [WHEN] The vendor template card is opened. + VendorTemplateCard.OpenView(); + VendorTemplateCard.GoToRecord(VendorTemplate); + + // [THEN] Only the VAT posting group is hidden. + Assert.IsFalse(VendorTemplateCard."VAT Bus. Posting Group".Visible(), 'Vendor template VAT posting group must be hidden when VAT is not in use.'); + Assert.IsTrue(VendorTemplateCard."Gen. Bus. Posting Group".Visible(), 'Vendor template general posting group must remain visible.'); + Assert.IsTrue(VendorTemplateCard."Vendor Posting Group".Visible(), 'Vendor posting group must remain visible.'); + VendorTemplateCard.Close(); + end; + + [Test] + procedure ResourceVATFieldHiddenWhenVATNotInUse() + var + Resource: Record Resource; + ResourceCard: TestPage "Resource Card"; + begin + // [FEATURE] [AI test 1.0] + // [SCENARIO] Resources hide VAT posting setup without hiding sales tax when VAT is not in use. + Initialize(); + + // [GIVEN] A resource with VAT in Use disabled while VAT and sales tax application areas are enabled. + SetVATInUse(false); + LibraryResource.CreateResourceNew(Resource); + + // [WHEN] The resource card is opened. + ResourceCard.OpenView(); + ResourceCard.GoToRecord(Resource); + + // [THEN] The VAT posting group is hidden and Tax Group Code remains visible. + VerifyResourceVATFieldVisibility(ResourceCard, false); + ResourceCard.Close(); + end; + + [Test] + procedure VATPostingFieldsVisibleWhenVATInUse() + var + ItemTemplate: Record "Item Templ."; + UpdatedItemTemplate: Record "Item Templ."; + GLAccount: Record "G/L Account"; + CustomerTemplate: Record "Customer Templ."; + VendorTemplate: Record "Vendor Templ."; + Resource: Record Resource; + UpdatedResource: Record Resource; + ItemTemplateCard: TestPage "Item Templ. Card"; + GLAccountCard: TestPage "G/L Account Card"; + CustomerTemplateCard: TestPage "Customer Templ. Card"; + VendorTemplateCard: TestPage "Vendor Templ. Card"; + ResourceCard: TestPage "Resource Card"; + begin + // [FEATURE] [AI test 1.0] + // [SCENARIO] VAT posting fields follow VAT in Use when the same template, account and resource cards are reopened. + Initialize(); + + // [GIVEN] Templates, a G/L account and a resource in a company that uses VAT. + SetVATInUse(true); + LibraryTemplates.CreateItemTemplateWithData(ItemTemplate); + LibraryERM.CreateGLAccount(GLAccount); + LibraryTemplates.CreateCustomerTemplate(CustomerTemplate); + LibraryTemplates.CreateVendorTemplate(VendorTemplate); + LibraryResource.CreateResourceNew(Resource); + + // [WHEN] The cards are opened. + ItemTemplateCard.OpenView(); + ItemTemplateCard.GoToRecord(ItemTemplate); + GLAccountCard.OpenView(); + GLAccountCard.GoToRecord(GLAccount); + CustomerTemplateCard.OpenView(); + CustomerTemplateCard.GoToRecord(CustomerTemplate); + VendorTemplateCard.OpenView(); + VendorTemplateCard.GoToRecord(VendorTemplate); + ResourceCard.OpenView(); + ResourceCard.GoToRecord(Resource); + + // [THEN] VAT posting fields and sales tax fields remain visible. + VerifyItemTemplateVATFieldVisibility(ItemTemplateCard, true); + VerifyGLAccountVATFieldVisibility(GLAccountCard, true); + Assert.IsTrue(CustomerTemplateCard."VAT Bus. Posting Group".Visible(), 'Customer template VAT posting group must be visible when VAT is in use.'); + Assert.IsTrue(VendorTemplateCard."VAT Bus. Posting Group".Visible(), 'Vendor template VAT posting group must be visible when VAT is in use.'); + VerifyResourceVATFieldVisibility(ResourceCard, true); + ResourceCard.Close(); + VendorTemplateCard.Close(); + CustomerTemplateCard.Close(); + GLAccountCard.Close(); + ItemTemplateCard.Close(); + + // [WHEN] VAT is disabled and the same records are reopened. + SetVATInUse(false); + ItemTemplateCard.OpenView(); + ItemTemplateCard.GoToRecord(ItemTemplate); + GLAccountCard.OpenView(); + GLAccountCard.GoToRecord(GLAccount); + CustomerTemplateCard.OpenView(); + CustomerTemplateCard.GoToRecord(CustomerTemplate); + VendorTemplateCard.OpenView(); + VendorTemplateCard.GoToRecord(VendorTemplate); + ResourceCard.OpenView(); + ResourceCard.GoToRecord(Resource); + + // [THEN] VAT posting fields are hidden without hiding sales tax or clearing stored VAT posting groups. + VerifyItemTemplateVATFieldVisibility(ItemTemplateCard, false); + VerifyGLAccountVATFieldVisibility(GLAccountCard, false); + Assert.IsFalse(CustomerTemplateCard."VAT Bus. Posting Group".Visible(), 'Customer template must reload VAT in Use when reopened.'); + Assert.IsFalse(VendorTemplateCard."VAT Bus. Posting Group".Visible(), 'Vendor template must reload VAT in Use when reopened.'); + VerifyResourceVATFieldVisibility(ResourceCard, false); + ResourceCard.Close(); + VendorTemplateCard.Close(); + CustomerTemplateCard.Close(); + GLAccountCard.Close(); + ItemTemplateCard.Close(); + + UpdatedItemTemplate.Get(ItemTemplate.Code); + UpdatedItemTemplate.TestField("VAT Prod. Posting Group", ItemTemplate."VAT Prod. Posting Group"); + UpdatedResource.Get(Resource."No."); + UpdatedResource.TestField("VAT Prod. Posting Group", Resource."VAT Prod. Posting Group"); + end; + + [Test] + procedure TemplateVATPricesHiddenWithoutVATApplicationArea() + begin + // [FEATURE] [AI test 1.0] + // [SCENARIO] Template VAT pricing fields are hidden for sales tax application areas even when VAT is in use. + Initialize(); + SetVATInUse(true); + LibraryApplicationArea.EnableSalesTaxSetup(); + VerifyTemplateVATPriceVisibility(false); + end; + + [Test] + procedure TemplateVATPricesVisibleWithVATApplicationArea() + begin + // [FEATURE] [AI test 1.0] + // [SCENARIO] Template VAT pricing fields follow their master cards when the VAT application area is enabled. + Initialize(); + SetVATInUse(false); + LibraryApplicationArea.EnableVATSetup(); + VerifyTemplateVATPriceVisibility(true); + end; + local procedure Initialize() var SalesSetup: Record "Sales & Receivables Setup"; @@ -1610,6 +1836,7 @@ codeunit 138012 "O365 Templates Test" DeleteConfigurationTemplates(); LibraryVariableStorage.Clear(); LibrarySetupStorage.Restore(); + LibraryApplicationArea.EnableFoundationSetup(); // Lazy Setup. if isInitialized then @@ -1629,11 +1856,11 @@ codeunit 138012 "O365 Templates Test" if not LibraryFiscalYear.AccountingPeriodsExists() then LibraryFiscalYear.CreateFiscalYear(); - LibraryApplicationArea.EnableFoundationSetup(); LibrarySetupStorage.Save(DATABASE::"Marketing Setup"); LibrarySetupStorage.Save(DATABASE::"Sales & Receivables Setup"); LibrarySetupStorage.Save(DATABASE::"Purchases & Payables Setup"); LibrarySetupStorage.Save(DATABASE::"Inventory Setup"); + LibrarySetupStorage.Save(DATABASE::"General Ledger Setup"); SalesSetup.Get(); SalesSetup."Stockout Warning" := false; @@ -1644,6 +1871,101 @@ codeunit 138012 "O365 Templates Test" LibraryTestInitialize.OnAfterTestSuiteInitialize(CODEUNIT::"O365 Templates Test"); end; + local procedure SetVATInUse(VATInUse: Boolean) + var + ApplicationAreaSetup: Record "Application Area Setup"; + GeneralLedgerSetup: Record "General Ledger Setup"; + ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade"; + begin + LibraryApplicationArea.EnableSalesTaxSetup(); + ApplicationAreaSetup.Get(CompanyName(), '', ''); + ApplicationAreaSetup.Validate(VAT, true); + ApplicationAreaSetup.Modify(true); + ApplicationAreaMgmtFacade.SetupApplicationArea(); + GeneralLedgerSetup.Get(); + GeneralLedgerSetup.Validate("VAT in Use", VATInUse); + GeneralLedgerSetup.Modify(true); + end; + + local procedure VerifyItemTemplateVATFieldVisibility(var ItemTemplateCard: TestPage "Item Templ. Card"; VATInUse: Boolean) + begin + Assert.AreEqual(VATInUse, ItemTemplateCard."VAT Prod. Posting Group".Visible(), 'Item template VAT posting field visibility must follow VAT in Use.'); + Assert.IsTrue(ItemTemplateCard."Tax Group Code".Visible(), 'Item template Tax Group Code must remain visible for sales tax.'); + end; + + local procedure VerifyGLAccountVATFieldVisibility(var GLAccountCard: TestPage "G/L Account Card"; VATInUse: Boolean) + begin + Assert.AreEqual(VATInUse, GLAccountCard."VAT Bus. Posting Group".Visible(), 'G/L account VAT business posting field visibility must follow VAT in Use.'); + Assert.AreEqual(VATInUse, GLAccountCard."VAT Prod. Posting Group".Visible(), 'G/L account VAT product posting field visibility must follow VAT in Use.'); + Assert.IsTrue(GLAccountCard."Tax Group Code".Visible(), 'G/L account Tax Group Code must remain visible for sales tax.'); + end; + + local procedure VerifyResourceVATFieldVisibility(var ResourceCard: TestPage "Resource Card"; VATInUse: Boolean) + begin + Assert.AreEqual(VATInUse, ResourceCard."VAT Prod. Posting Group".Visible(), 'Resource VAT posting field visibility must follow VAT in Use.'); + Assert.IsTrue(ResourceCard."Tax Group Code".Visible(), 'Resource Tax Group Code must remain visible for sales tax.'); + end; + + local procedure VerifyTemplateVATPriceVisibility(ExpectedVisible: Boolean) + var + ItemTemplate: Record "Item Templ."; + CustomerTemplate: Record "Customer Templ."; + VendorTemplate: Record "Vendor Templ."; + ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade"; + ExpectedErrorMessage: Text; + ItemTemplateCard: TestPage "Item Templ. Card"; + CustomerTemplateCard: TestPage "Customer Templ. Card"; + VendorTemplateCard: TestPage "Vendor Templ. Card"; + begin + Assert.AreEqual(ExpectedVisible, ApplicationAreaMgmtFacade.IsVATEnabled(), 'The VAT application area must match the test scenario.'); + // Each template is created right before its page check because asserterror rolls back uncommitted data. + LibraryTemplates.CreateItemTemplate(ItemTemplate); + ItemTemplateCard.OpenView(); + ItemTemplateCard.GoToRecord(ItemTemplate); + if ExpectedVisible then + Assert.IsTrue(ItemTemplateCard."Price Includes VAT".Visible(), 'Item template VAT pricing must be visible when the VAT application area is enabled.') + else begin + ExpectedErrorMessage := GetPageFieldNotFoundError(Page::"Item Templ. Card", 'Price Includes VAT'); + asserterror ItemTemplateCard."Price Includes VAT".Activate(); + Assert.ExpectedError(ExpectedErrorMessage); + end; + ItemTemplateCard.Close(); + + LibraryTemplates.CreateCustomerTemplate(CustomerTemplate); + CustomerTemplateCard.OpenView(); + CustomerTemplateCard.GoToRecord(CustomerTemplate); + if ExpectedVisible then + Assert.IsTrue(CustomerTemplateCard."Prices Including VAT".Visible(), 'Customer template VAT pricing must be visible when the VAT application area is enabled.') + else begin + ExpectedErrorMessage := GetPageFieldNotFoundError(Page::"Customer Templ. Card", 'Prices Including VAT'); + asserterror CustomerTemplateCard."Prices Including VAT".Activate(); + Assert.ExpectedError(ExpectedErrorMessage); + end; + CustomerTemplateCard.Close(); + + LibraryTemplates.CreateVendorTemplate(VendorTemplate); + VendorTemplateCard.OpenView(); + VendorTemplateCard.GoToRecord(VendorTemplate); + if ExpectedVisible then + Assert.IsTrue(VendorTemplateCard."Prices Including VAT".Visible(), 'Vendor template VAT pricing must be visible when the VAT application area is enabled.') + else begin + ExpectedErrorMessage := GetPageFieldNotFoundError(Page::"Vendor Templ. Card", 'Prices Including VAT'); + asserterror VendorTemplateCard."Prices Including VAT".Activate(); + Assert.ExpectedError(ExpectedErrorMessage); + end; + VendorTemplateCard.Close(); + end; + + local procedure GetPageFieldNotFoundError(PageID: Integer; ControlName: Text): Text + var + PageControlField: Record "Page Control Field"; + begin + PageControlField.SetRange(PageNo, PageID); + PageControlField.SetRange(ControlName, ControlName); + PageControlField.FindFirst(); + exit(StrSubstNo(PageFieldNotFoundErr, PageControlField.ControlId)); + end; + local procedure ClearTable(TableID: Integer) var Job: Record Job;