From c3d3d53a9b8b2dc13fab45d82bc74aa350f87329 Mon Sep 17 00:00:00 2001 From: v-nehanawal Date: Wed, 15 Jul 2026 18:12:40 +0530 Subject: [PATCH 1/5] Initial Commit --- .../VATReportingDateMgt.Codeunit.al | 39 ++++++++++++++++++- .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 39 +++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src/Layers/W1/BaseApp/Finance/VAT/Calculation/VATReportingDateMgt.Codeunit.al b/src/Layers/W1/BaseApp/Finance/VAT/Calculation/VATReportingDateMgt.Codeunit.al index 12615b0735..7f89837929 100644 --- a/src/Layers/W1/BaseApp/Finance/VAT/Calculation/VATReportingDateMgt.Codeunit.al +++ b/src/Layers/W1/BaseApp/Finance/VAT/Calculation/VATReportingDateMgt.Codeunit.al @@ -5,6 +5,7 @@ namespace Microsoft.Finance.VAT.Calculation; using Microsoft.Finance.GeneralLedger.Ledger; +using Microsoft.Finance.GeneralLedger.Posting; using Microsoft.Finance.GeneralLedger.Setup; using Microsoft.Finance.VAT.Ledger; using Microsoft.Finance.VAT.Reporting; @@ -58,6 +59,8 @@ codeunit 799 "VAT Reporting Date Mgt" VATDateNotAllowedErr: Label 'The VAT Date is not within the range of allowed VAT dates.'; VATDateInPeriodNotAllowedErr: Label 'The specified VAT Date is in a %1 VAT Return Period which was not allowed', Comment = '%1 - VAT Return Period status'; VATDateFromPeriodNotAllowedErr: Label 'The VAT Date is in a %1 VAT Return Period and was not allowed to change', Comment = '%1 - VAT Return Period status'; + ConfirmedVATReturnPeriodDates: List of [Date]; + RejectedVATReturnPeriodDates: List of [Date]; /// /// Updates linked entries when VAT entry VAT reporting date is modified. @@ -253,7 +256,7 @@ codeunit 799 "VAT Reporting Date Mgt" end; VATReturnPeriod.CalcFields("VAT Return Status"); if VATReturnPeriod."VAT Return Status" in [VATReturnPeriod."VAT Return Status"::Released, VATReturnPeriod."VAT Return Status"::Submitted] then - if not ConfirmManagement.GetResponseOrDefault(StrSubstNo(VATReturnWarning, Format(VATReturnPeriod."VAT Return Status")), true) then + if not GetVATReturnPeriodWarningResponse(VATDate, StrSubstNo(VATReturnWarning, Format(VATReturnPeriod."VAT Return Status"))) then ErrorMessageManagement.LogContextFieldError(ContextFieldNo, StrSubstNo(VATPeriodErr, VATReturnPeriod."VAT Return Status"), VATReturnPeriod, VATReturnPeriod.FieldNo(VATReturnPeriod."VAT Return Status"), ForwardLinkMgt.GetHelpCodeForAllowedVATDate()); end; GLSetup."Control VAT Period"::"Block posting within closed period": @@ -261,11 +264,43 @@ codeunit 799 "VAT Reporting Date Mgt" ErrorMessageManagement.LogContextFieldError(ContextFieldNo, ClosedError, VATReturnPeriod, VATReturnPeriod.FieldNo(VATReturnPeriod.Status), ForwardLinkMgt.GetHelpCodeForAllowedVATDate()); GLSetup."Control VAT Period"::"Warn when posting in closed period": if VATReturnPeriod.Status = VATReturnPeriod.Status::Closed then - if not ConfirmManagement.GetResponseOrDefault(StrSubstNo(VATReturnWarning, Format(VATReturnPeriod.Status::Closed)), true) then + if not GetVATReturnPeriodWarningResponse(VATDate, StrSubstNo(VATReturnWarning, Format(VATReturnPeriod.Status::Closed))) then ErrorMessageManagement.LogContextFieldError(ContextFieldNo, StrSubstNo(VATPeriodErr, VATReturnPeriod.Status), VATReturnPeriod, VATReturnPeriod.FieldNo(VATReturnPeriod.Status), ForwardLinkMgt.GetHelpCodeForAllowedVATDate()); end; end; + local procedure GetVATReturnPeriodWarningResponse(VATDate: Date; WarningMsg: Text): Boolean + begin + if ConfirmedVATReturnPeriodDates.Contains(VATDate) then + exit(true); + if RejectedVATReturnPeriodDates.Contains(VATDate) then + exit(false); + + if ConfirmManagement.GetResponseOrDefault(WarningMsg, true) then begin + ConfirmedVATReturnPeriodDates.Add(VATDate); + exit(true); + end; + + RejectedVATReturnPeriodDates.Add(VATDate); + exit(false); + end; + + procedure ResetVATReturnPeriodWarning() + begin + Clear(ConfirmedVATReturnPeriodDates); + Clear(RejectedVATReturnPeriodDates); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnAfterFinishPosting, '', false, false)] + local procedure ResetVATReturnPeriodWarningOnAfterFinishPosting(var IsTransactionConsistent: Boolean) + begin + // Reset only when the whole transaction has been posted (balanced), not between the individual general + // journal lines of the same document. This keeps the warning deduplicated within a posting while still + // prompting again for the next posting. + if IsTransactionConsistent then + ResetVATReturnPeriodWarning(); + end; + local procedure UpdateGLEntries(VATEntry: Record "VAT Entry") var GLEntry: Record "G/L Entry"; diff --git a/src/Layers/W1/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/W1/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index bbba9e8220..035e77c8fc 100644 --- a/src/Layers/W1/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/W1/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -758,6 +758,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/W1/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/W1/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index 99d853653a..a67d84c91c 100644 --- a/src/Layers/W1/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/W1/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -43,6 +43,7 @@ VATDateOutOfVATDatesErr: Label 'The VAT Date is not within the range of allowed VAT dates.'; VATEntrySettlementChangeErr: Label 'You cannot change the contents of this field when %1 is %2.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; + WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -5367,6 +5368,36 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; + [Test] + [HandlerFunctions('ConfirmHandlerCountTrue')] + procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + VATReturnPeriod: Record "VAT Return Period"; + VATReportHeader: Record "VAT Report Header"; + DocNo: Code[20]; + VATDate: Date; + begin + // [FEATURE] [VAT] + // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period + Initialize(); + + // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" + // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it + VATDate := CalcDate('<1Y>', WorkDate()); + CleanVATReturnPeriod(); + CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); + + // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning + DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); + + // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once + SalesInvoiceHeader.Get(DocNo); + Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); + LibraryVariableStorage.DequeueText(); + LibraryVariableStorage.AssertEmpty(); + end; + local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -6816,6 +6847,14 @@ Reply := false; end; + [ConfirmHandler] + [Scope('OnPrem')] + procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) + begin + LibraryVariableStorage.Enqueue(Question); + Reply := true; + end; + [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var From 5df2a08d51d72d65fae54c89a32034a232dfea19 Mon Sep 17 00:00:00 2001 From: v-nehanawal Date: Wed, 15 Jul 2026 18:14:45 +0530 Subject: [PATCH 2/5] Invoke Miapp --- .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 39 +++++++++++++++++++ .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 39 +++++++++++++++++++ .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 39 +++++++++++++++++++ .../Finance/VAT/Ledger/VATEntry.Table.al | 2 + .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 39 +++++++++++++++++++ .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 39 +++++++++++++++++++ .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 39 +++++++++++++++++++ .../Finance/VAT/Ledger/VATEntry.Table.al | 1 + .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 39 +++++++++++++++++++ 19 files changed, 286 insertions(+) diff --git a/src/Layers/APAC/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/APAC/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 49ee5baf52..01df9e03cd 100644 --- a/src/Layers/APAC/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/APAC/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -761,6 +761,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/BE/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/BE/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index c35aff10d9..626cd98003 100644 --- a/src/Layers/BE/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/BE/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -761,6 +761,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/BE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/BE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index 23b0f3a2e4..67b7b4c26c 100644 --- a/src/Layers/BE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/BE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -43,6 +43,7 @@ VATDateOutOfVATDatesErr: Label 'The VAT Date is not within the range of allowed VAT dates.'; VATEntrySettlementChangeErr: Label 'You cannot change the contents of this field when %1 is %2.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; + WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -5364,6 +5365,36 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; + [Test] + [HandlerFunctions('ConfirmHandlerCountTrue')] + procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + VATReturnPeriod: Record "VAT Return Period"; + VATReportHeader: Record "VAT Report Header"; + DocNo: Code[20]; + VATDate: Date; + begin + // [FEATURE] [VAT] + // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period + Initialize(); + + // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" + // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it + VATDate := CalcDate('<1Y>', WorkDate()); + CleanVATReturnPeriod(); + CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); + + // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning + DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); + + // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once + SalesInvoiceHeader.Get(DocNo); + Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); + LibraryVariableStorage.DequeueText(); + LibraryVariableStorage.AssertEmpty(); + end; + local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -6825,6 +6856,14 @@ LibrarySales.CreateCustomerWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Post Reply := false; end; + [ConfirmHandler] + [Scope('OnPrem')] + procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) + begin + LibraryVariableStorage.Enqueue(Question); + Reply := true; + end; + [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var diff --git a/src/Layers/CH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/CH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 4d24c9a72b..93e38346d5 100644 --- a/src/Layers/CH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/CH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -758,6 +758,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/CZ/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/CZ/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index e02cea6037..77cf44cda1 100644 --- a/src/Layers/CZ/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/CZ/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -43,6 +43,7 @@ VATDateOutOfVATDatesErr: Label 'The VAT Date is not within the range of allowed VAT dates.'; VATEntrySettlementChangeErr: Label 'You cannot change the contents of this field when %1 is %2.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; + WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -5110,6 +5111,36 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; + [Test] + [HandlerFunctions('ConfirmHandlerCountTrue')] + procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + VATReturnPeriod: Record "VAT Return Period"; + VATReportHeader: Record "VAT Report Header"; + DocNo: Code[20]; + VATDate: Date; + begin + // [FEATURE] [VAT] + // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period + Initialize(); + + // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" + // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it + VATDate := CalcDate('<1Y>', WorkDate()); + CleanVATReturnPeriod(); + CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); + + // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning + DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); + + // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once + SalesInvoiceHeader.Get(DocNo); + Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); + LibraryVariableStorage.DequeueText(); + LibraryVariableStorage.AssertEmpty(); + end; + local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -6478,6 +6509,14 @@ Reply := false; end; + [ConfirmHandler] + [Scope('OnPrem')] + procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) + begin + LibraryVariableStorage.Enqueue(Question); + Reply := true; + end; + [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var diff --git a/src/Layers/DACH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/DACH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 2fe622dea4..9d9f43ede5 100644 --- a/src/Layers/DACH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/DACH/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -758,6 +758,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/DE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/DE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index 178de53ce4..5e342241f1 100644 --- a/src/Layers/DE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/DE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -43,6 +43,7 @@ VATDateOutOfVATDatesErr: Label 'The VAT Date is not within the range of allowed VAT dates.'; VATEntrySettlementChangeErr: Label 'You cannot change the contents of this field when %1 is %2.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; + WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -5365,6 +5366,36 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; + [Test] + [HandlerFunctions('ConfirmHandlerCountTrue')] + procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + VATReturnPeriod: Record "VAT Return Period"; + VATReportHeader: Record "VAT Report Header"; + DocNo: Code[20]; + VATDate: Date; + begin + // [FEATURE] [VAT] + // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period + Initialize(); + + // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" + // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it + VATDate := CalcDate('<1Y>', WorkDate()); + CleanVATReturnPeriod(); + CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); + + // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning + DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); + + // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once + SalesInvoiceHeader.Get(DocNo); + Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); + LibraryVariableStorage.DequeueText(); + LibraryVariableStorage.AssertEmpty(); + end; + local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -6821,6 +6852,14 @@ LibrarySales.CreateCustomerWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Post Reply := false; end; + [ConfirmHandler] + [Scope('OnPrem')] + procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) + begin + LibraryVariableStorage.Enqueue(Question); + Reply := true; + end; + [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var diff --git a/src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 0dc9f24abe..0656da39d4 100644 --- a/src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -765,6 +765,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); @@ -1617,6 +1618,7 @@ table 254 "VAT Entry" local procedure OnAfterSetGLAccountNo(var VATEntry: Record "VAT Entry"; var IsHandled: Boolean; WithUI: Boolean) begin end; +<<<<<<< src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al [IntegrationEvent(false, false)] local procedure OnAfterUpdateRates(var VATEntry: Record "VAT Entry"; VATPostingSetup: Record "VAT Posting Setup") diff --git a/src/Layers/ES/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/ES/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index d978c94d0a..c753dbb206 100644 --- a/src/Layers/ES/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/ES/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -43,6 +43,7 @@ VATDateOutOfVATDatesErr: Label 'The VAT Date is not within the range of allowed VAT dates.'; VATEntrySettlementChangeErr: Label 'You cannot change the contents of this field when %1 is %2.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; + WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -5411,6 +5412,36 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; + [Test] + [HandlerFunctions('ConfirmHandlerCountTrue')] + procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + VATReturnPeriod: Record "VAT Return Period"; + VATReportHeader: Record "VAT Report Header"; + DocNo: Code[20]; + VATDate: Date; + begin + // [FEATURE] [VAT] + // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period + Initialize(); + + // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" + // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it + VATDate := CalcDate('<1Y>', WorkDate()); + CleanVATReturnPeriod(); + CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); + + // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning + DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); + + // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once + SalesInvoiceHeader.Get(DocNo); + Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); + LibraryVariableStorage.DequeueText(); + LibraryVariableStorage.AssertEmpty(); + end; + local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -6945,6 +6976,14 @@ LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Pos Reply := false; end; + [ConfirmHandler] + [Scope('OnPrem')] + procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) + begin + LibraryVariableStorage.Enqueue(Question); + Reply := true; + end; + [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var diff --git a/src/Layers/FI/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/FI/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 8850605176..3a598c16b5 100644 --- a/src/Layers/FI/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/FI/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -758,6 +758,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/FR/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/FR/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 80d76bc4a1..4def158cd0 100644 --- a/src/Layers/FR/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/FR/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -758,6 +758,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/IT/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/IT/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index a8ac141409..9226040838 100644 --- a/src/Layers/IT/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/IT/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -768,6 +768,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index 6ec4f46280..fb1e95922c 100644 --- a/src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -34,6 +34,7 @@ TooManyValuableSalesEntriesErr: Label 'Too many valuable Sales Lines found.', Comment = '.'; TooManyValuablePurchaseEntriesErr: Label 'Too many valuable Purchase Lines found.', Comment = '.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; + WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -2731,6 +2732,36 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; + [Test] + [HandlerFunctions('ConfirmHandlerCountTrue')] + procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + VATReturnPeriod: Record "VAT Return Period"; + VATReportHeader: Record "VAT Report Header"; + DocNo: Code[20]; + VATDate: Date; + begin + // [FEATURE] [VAT] + // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period + Initialize(); + + // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" + // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it + VATDate := CalcDate('<1Y>', WorkDate()); + CleanVATReturnPeriod(); + CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); + + // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning + DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); + + // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once + SalesInvoiceHeader.Get(DocNo); + Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); + LibraryVariableStorage.DequeueText(); + LibraryVariableStorage.AssertEmpty(); + end; + local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -3950,6 +3981,14 @@ Reply := false; end; + [ConfirmHandler] + [Scope('OnPrem')] + procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) + begin + LibraryVariableStorage.Enqueue(Question); + Reply := true; + end; + [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var diff --git a/src/Layers/NA/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/NA/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 2150a1cf2f..1f6679e030 100644 --- a/src/Layers/NA/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/NA/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -758,6 +758,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/NL/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/NL/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 3b7436a36d..e373bfc1f9 100644 --- a/src/Layers/NL/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/NL/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -758,6 +758,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/NO/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/NO/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 37475efe86..38fcdee4a5 100644 --- a/src/Layers/NO/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/NO/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -759,6 +759,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/NO/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/NO/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index eb969a0818..e4edb05fc6 100644 --- a/src/Layers/NO/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/NO/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -43,6 +43,7 @@ VATDateOutOfVATDatesErr: Label 'The VAT Date is not within the range of allowed VAT dates.'; VATEntrySettlementChangeErr: Label 'You cannot change the contents of this field when %1 is %2.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; + WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -5349,6 +5350,36 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; + [Test] + [HandlerFunctions('ConfirmHandlerCountTrue')] + procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + VATReturnPeriod: Record "VAT Return Period"; + VATReportHeader: Record "VAT Report Header"; + DocNo: Code[20]; + VATDate: Date; + begin + // [FEATURE] [VAT] + // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period + Initialize(); + + // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" + // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it + VATDate := CalcDate('<1Y>', WorkDate()); + CleanVATReturnPeriod(); + CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); + + // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning + DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); + + // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once + SalesInvoiceHeader.Get(DocNo); + Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); + LibraryVariableStorage.DequeueText(); + LibraryVariableStorage.AssertEmpty(); + end; + local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -6800,6 +6831,14 @@ Reply := false; end; + [ConfirmHandler] + [Scope('OnPrem')] + procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) + begin + LibraryVariableStorage.Enqueue(Question); + Reply := true; + end; + [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var diff --git a/src/Layers/RU/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/RU/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 74db5b9c85..ed3e2fc1f1 100644 --- a/src/Layers/RU/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/RU/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -763,6 +763,7 @@ table 254 "VAT Entry" if Closed then Error(VATDateModifiableClosedErr); + VATDateReportingMgt.ResetVATReturnPeriodWarning(); VATDateReportingMgt.CheckDateAllowed("VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), false); VATDateReportingMgt.CheckDateAllowed(xRec."VAT Reporting Date", Rec.FieldNo("VAT Reporting Date"), true, false); VATDateReportingMgt.UpdateLinkedEntries(Rec); diff --git a/src/Layers/RU/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/RU/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index 945768ca44..b9142ae740 100644 --- a/src/Layers/RU/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/RU/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -43,6 +43,7 @@ VATDateOutOfVATDatesErr: Label 'The VAT Date is not within the range of allowed VAT dates.'; VATEntrySettlementChangeErr: Label 'You cannot change the contents of this field when %1 is %2.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; + WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -5310,6 +5311,36 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; + [Test] + [HandlerFunctions('ConfirmHandlerCountTrue')] + procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() + var + SalesInvoiceHeader: Record "Sales Invoice Header"; + VATReturnPeriod: Record "VAT Return Period"; + VATReportHeader: Record "VAT Report Header"; + DocNo: Code[20]; + VATDate: Date; + begin + // [FEATURE] [VAT] + // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period + Initialize(); + + // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" + // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it + VATDate := CalcDate('<1Y>', WorkDate()); + CleanVATReturnPeriod(); + CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); + + // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning + DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); + + // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once + SalesInvoiceHeader.Get(DocNo); + Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); + LibraryVariableStorage.DequeueText(); + LibraryVariableStorage.AssertEmpty(); + end; + local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -6689,6 +6720,14 @@ Reply := false; end; + [ConfirmHandler] + [Scope('OnPrem')] + procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) + begin + LibraryVariableStorage.Enqueue(Question); + Reply := true; + end; + [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var From 32e2736143b4066f1c67800b3ef4134fe23e035b Mon Sep 17 00:00:00 2001 From: v-nehanawal Date: Wed, 15 Jul 2026 19:10:40 +0530 Subject: [PATCH 3/5] ES fix --- src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al b/src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al index 0656da39d4..dbda7f2bf9 100644 --- a/src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al +++ b/src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al @@ -1618,7 +1618,6 @@ table 254 "VAT Entry" local procedure OnAfterSetGLAccountNo(var VATEntry: Record "VAT Entry"; var IsHandled: Boolean; WithUI: Boolean) begin end; -<<<<<<< src/Layers/ES/BaseApp/Finance/VAT/Ledger/VATEntry.Table.al [IntegrationEvent(false, false)] local procedure OnAfterUpdateRates(var VATEntry: Record "VAT Entry"; VATPostingSetup: Record "VAT Posting Setup") From 1d5ac9f0b35a36731a706e3bda6b1bce33445e50 Mon Sep 17 00:00:00 2001 From: v-nehanawal Date: Wed, 15 Jul 2026 21:54:56 +0530 Subject: [PATCH 4/5] IT fix --- .../Tests/VAT/ERMVATSalesPurchase.Codeunit.al | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al b/src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al index fb1e95922c..9a2e873d0d 100644 --- a/src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al +++ b/src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al @@ -34,7 +34,6 @@ TooManyValuableSalesEntriesErr: Label 'Too many valuable Sales Lines found.', Comment = '.'; TooManyValuablePurchaseEntriesErr: Label 'Too many valuable Purchase Lines found.', Comment = '.'; TotalVATAmountErr: Label 'Total VAT Amount must be zero'; - WarningShownOnceErr: Label 'The VAT Return Period warning should be shown only once for the same VAT date.'; [Test] procedure VerifyVATDateEqualsToPostingDate() @@ -2732,36 +2731,6 @@ TempVATAmountLine.FieldCaption("Amount Including VAT")); end; - [Test] - [HandlerFunctions('ConfirmHandlerCountTrue')] - procedure CachedResponseUsedForSameVATDateWithReleasedPeriod() - var - SalesInvoiceHeader: Record "Sales Invoice Header"; - VATReturnPeriod: Record "VAT Return Period"; - VATReportHeader: Record "VAT Report Header"; - DocNo: Code[20]; - VATDate: Date; - begin - // [FEATURE] [VAT] - // [SCENARIO 639895] Warning is shown only once when a sales invoice with several VAT posting group combinations is posted with a VAT date in a Released VAT Return Period - Initialize(); - - // [GIVEN] "Control VAT Period" is "Block posting within closed and warn for released period" - // [GIVEN] A distinct VAT date "D" and a Released VAT Return Period "P" that covers it - VATDate := CalcDate('<1Y>', WorkDate()); - CleanVATReturnPeriod(); - CreateVATReturnPeriod(VATReturnPeriod.Status::Open, VATReportHeader.Status::Released, VATDate, VATDate + 1); - - // [WHEN] Posting a sales invoice "I" with two lines that use different VAT Product Posting Groups and VAT date "D", confirming the warning - DocNo := CreateAndPostSalesDocWithTwoLines(VATDate, Enum::"Gen. Journal Document Type"::Invoice); - - // [THEN] Sales invoice "I" is posted and the confirmation warning is shown only once - SalesInvoiceHeader.Get(DocNo); - Assert.AreEqual(1, LibraryVariableStorage.Length(), WarningShownOnceErr); - LibraryVariableStorage.DequeueText(); - LibraryVariableStorage.AssertEmpty(); - end; - local procedure Initialize() var PurchaseHeader: Record "Purchase Header"; @@ -3981,14 +3950,6 @@ Reply := false; end; - [ConfirmHandler] - [Scope('OnPrem')] - procedure ConfirmHandlerCountTrue(Question: Text[1024]; var Reply: Boolean) - begin - LibraryVariableStorage.Enqueue(Question); - Reply := true; - end; - [RequestPageHandler] procedure BatchPostSalesInvoicesRequestPageHandler(var BatchPostSalesInvoices: TestRequestPage "Batch Post Sales Invoices") var @@ -4137,4 +4098,5 @@ Assert.IsFalse(BatchPostPurchCreditMemos.VATDate.Visible(), ''); Assert.IsFalse(BatchPostPurchCreditMemos.ReplaceVATDate.Visible(), ''); end; + } From 85bc41e38a92bd5a1213e958ad3fa81239e7fc8b Mon Sep 17 00:00:00 2001 From: v-nehanawal Date: Thu, 16 Jul 2026 18:35:20 +0530 Subject: [PATCH 5/5] Issue fix --- .../VAT/Calculation/VATReportingDateMgt.Codeunit.al | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Layers/W1/BaseApp/Finance/VAT/Calculation/VATReportingDateMgt.Codeunit.al b/src/Layers/W1/BaseApp/Finance/VAT/Calculation/VATReportingDateMgt.Codeunit.al index 7f89837929..527218b8b8 100644 --- a/src/Layers/W1/BaseApp/Finance/VAT/Calculation/VATReportingDateMgt.Codeunit.al +++ b/src/Layers/W1/BaseApp/Finance/VAT/Calculation/VATReportingDateMgt.Codeunit.al @@ -291,12 +291,16 @@ codeunit 799 "VAT Reporting Date Mgt" Clear(RejectedVATReturnPeriodDates); end; + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnBeforeCode, '', false, false)] + local procedure ResetVATReturnPeriodWarningOnBeforeGenJnlPostLineCode(var GLEntryNo: Integer) + begin + if GLEntryNo = 0 then + ResetVATReturnPeriodWarning(); + end; + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", OnAfterFinishPosting, '', false, false)] local procedure ResetVATReturnPeriodWarningOnAfterFinishPosting(var IsTransactionConsistent: Boolean) begin - // Reset only when the whole transaction has been posted (balanced), not between the individual general - // journal lines of the same document. This keeps the warning deduplicated within a posting while still - // prompting again for the next posting. if IsTransactionConsistent then ResetVATReturnPeriodWarning(); end;