Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/Layers/BE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions src/Layers/CZ/Tests/VAT/ERMVATSalesPurchase.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions src/Layers/DE/Tests/VAT/ERMVATSalesPurchase.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions src/Layers/ES/Tests/VAT/ERMVATSalesPurchase.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions src/Layers/IT/Tests/VAT/ERMVATSalesPurchase.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions src/Layers/NO/Tests/VAT/ERMVATSalesPurchase.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading