Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -3714,6 +3714,7 @@ table 39 "Purchase Line"
begin
NonDeductibleVAT.CheckPrepmtWithNonDeductubleVATInPurchaseLine(Rec);
NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed(Rec);
CheckNonDedVATPctConsistencyForZeroLine();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

This adds a new error path to the shipped OnValidate trigger of field 6200 "Non-Deductible VAT %": existing extensions, integrations, or data-migration code that previously called Validate("Non-Deductible VAT %", 0) successfully can now fail when another line on the same document has the same VAT Identifier with a different percentage. Preserve the released field-trigger behavior or move the stricter consistency check behind a compatible opt-in path; BCQuality has no knowledge-backed rule for trigger-behavior breaks yet, so this functional breaking change can only be emitted as an agent finding.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

UpdateAmounts();
end;
}
Expand Down Expand Up @@ -4377,6 +4378,7 @@ table 39 "Purchase Line"
InvoiceOrOrderDocTypeErr: Label '%1 must be either %2 or %3.', Comment = '%1 - Document Type; %2, %3 - Purchase Document Type, Invoice or Order';
CannotInsertPurchLineWithoutHeaderErr: Label 'You cannot insert a purchase line without a purchase header.';
MustSpecifyErr: Label 'You must either specify %1 or %2.', Comment = '%1 = Field Caption; %2 = Field Caption';
DifferentNonDedVATRatesSameVATIdentifierErr: Label 'You cannot set different Non-Deductible VAT % for the combinations of business and product groups with the same VAT identifier.\The following combination with the same VAT identifier has different Non-Deductible VAT %: business group %1, product group %2', Comment = '%1 = VAT business posting group code, %2 = VAT product posting group code';

protected var
Currency: Record Currency;
Expand Down Expand Up @@ -10993,6 +10995,26 @@ table 39 "Purchase Line"
FieldError(Quantity, StrSubstNo(CorrectiveCreditMemoQtyIncreaseErr, xPurchaseLine.Quantity));
end;

local procedure CheckNonDedVATPctConsistencyForZeroLine()
var
PurchLine: Record "Purchase Line";
begin
if "Non-Deductible VAT %" <> 0 then
exit;
if "VAT Identifier" = '' then
exit;
if not NonDeductibleVAT.IsNonDeductibleVATEnabled() then
exit;

PurchLine.SetRange("Document Type", "Document Type");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

CheckNonDedVATPctConsistencyForZeroLine() only reads "VAT Bus. Posting Group" and "VAT Prod. Posting Group", but its FindFirst() on the wide "Purchase Line" table does not call SetLoadFields(), so each validation loads a full row just to build the error text. Add SetLoadFields("VAT Bus. Posting Group", "VAT Prod. Posting Group") before the read.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

PurchLine.SetRange("Document No.", "Document No.");
PurchLine.SetFilter("Line No.", '<>%1', "Line No.");
PurchLine.SetRange("VAT Identifier", "VAT Identifier");
PurchLine.SetFilter("Non-Deductible VAT %", '<>%1', "Non-Deductible VAT %");
if PurchLine.FindFirst() then
Error(DifferentNonDedVATRatesSameVATIdentifierErr, PurchLine."VAT Bus. Posting Group", PurchLine."VAT Prod. Posting Group");
end;

[IntegrationEvent(false, false)]
local procedure OnAfterInitDefaultDimensionSources(var PurchaseLine: Record "Purchase Line"; var DefaultDimSource: List of [Dictionary of [Integer, Code[20]]]; FieldNo: Integer)
begin
Expand Down
22 changes: 22 additions & 0 deletions src/Layers/BE/BaseApp/Purchases/Document/PurchaseLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -3690,6 +3690,7 @@ table 39 "Purchase Line"
begin
NonDeductibleVAT.CheckPrepmtWithNonDeductubleVATInPurchaseLine(Rec);
NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed(Rec);
CheckNonDedVATPctConsistencyForZeroLine();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

This adds a new error path to the shipped OnValidate trigger of field 6200 "Non-Deductible VAT %": existing extensions, integrations, or data-migration code that previously called Validate("Non-Deductible VAT %", 0) successfully can now fail when another line on the same document has the same VAT Identifier with a different percentage. Preserve the released field-trigger behavior or move the stricter consistency check behind a compatible opt-in path; BCQuality has no knowledge-backed rule for trigger-behavior breaks yet, so this functional breaking change can only be emitted as an agent finding.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

UpdateAmounts();
end;
}
Expand Down Expand Up @@ -4296,6 +4297,7 @@ table 39 "Purchase Line"
InvoiceOrOrderDocTypeErr: Label '%1 must be either %2 or %3.', Comment = '%1 - Document Type; %2, %3 - Purchase Document Type, Invoice or Order';
CannotInsertPurchLineWithoutHeaderErr: Label 'You cannot insert a purchase line without a purchase header.';
MustSpecifyErr: Label 'You must either specify %1 or %2.', Comment = '%1 = Field Caption; %2 = Field Caption';
DifferentNonDedVATRatesSameVATIdentifierErr: Label 'You cannot set different Non-Deductible VAT % for the combinations of business and product groups with the same VAT identifier.\The following combination with the same VAT identifier has different Non-Deductible VAT %: business group %1, product group %2', Comment = '%1 = VAT business posting group code, %2 = VAT product posting group code';

protected var
Currency: Record Currency;
Expand Down Expand Up @@ -10411,6 +10413,26 @@ table 39 "Purchase Line"
exit("Matched Inv./Cr. Memo Lines" > 0);
end;

local procedure CheckNonDedVATPctConsistencyForZeroLine()
var
PurchLine: Record "Purchase Line";
begin
if "Non-Deductible VAT %" <> 0 then
exit;
if "VAT Identifier" = '' then
exit;
if not NonDeductibleVAT.IsNonDeductibleVATEnabled() then
exit;

PurchLine.SetRange("Document Type", "Document Type");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

CheckNonDedVATPctConsistencyForZeroLine() only reads "VAT Bus. Posting Group" and "VAT Prod. Posting Group", but its FindFirst() on the wide "Purchase Line" table does not call SetLoadFields(), so each validation loads a full row just to build the error text. Add SetLoadFields("VAT Bus. Posting Group", "VAT Prod. Posting Group") before the read.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

PurchLine.SetRange("Document No.", "Document No.");
PurchLine.SetFilter("Line No.", '<>%1', "Line No.");
PurchLine.SetRange("VAT Identifier", "VAT Identifier");
PurchLine.SetFilter("Non-Deductible VAT %", '<>%1', "Non-Deductible VAT %");
if PurchLine.FindFirst() then
Error(DifferentNonDedVATRatesSameVATIdentifierErr, PurchLine."VAT Bus. Posting Group", PurchLine."VAT Prod. Posting Group");
end;

local procedure CheckCorrectiveCreditMemoQtyIncrease(xPurchaseLine: Record "Purchase Line")
begin
if not ("Copied From Posted Doc." and IsCreditDocType()) then
Expand Down
22 changes: 22 additions & 0 deletions src/Layers/CH/BaseApp/Purchases/Document/PurchaseLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -3692,6 +3692,7 @@ table 39 "Purchase Line"
begin
NonDeductibleVAT.CheckPrepmtWithNonDeductubleVATInPurchaseLine(Rec);
NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed(Rec);
CheckNonDedVATPctConsistencyForZeroLine();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

This adds a new error path to the shipped OnValidate trigger of field 6200 "Non-Deductible VAT %": existing extensions, integrations, or data-migration code that previously called Validate("Non-Deductible VAT %", 0) successfully can now fail when another line on the same document has the same VAT Identifier with a different percentage. Preserve the released field-trigger behavior or move the stricter consistency check behind a compatible opt-in path; BCQuality has no knowledge-backed rule for trigger-behavior breaks yet, so this functional breaking change can only be emitted as an agent finding.

The same issue exists in these regional copies — apply the equivalent fix in each:

  • src/Layers/ES/BaseApp/Purchases/Document/PurchaseLine.Table.al:3695 (ES)
  • src/Layers/NO/BaseApp/Purchases/Document/PurchaseLine.Table.al:3695 (NO)

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

UpdateAmounts();
end;
}
Expand Down Expand Up @@ -4295,6 +4296,7 @@ table 39 "Purchase Line"
InvoiceOrOrderDocTypeErr: Label '%1 must be either %2 or %3.', Comment = '%1 - Document Type; %2, %3 - Purchase Document Type, Invoice or Order';
CannotInsertPurchLineWithoutHeaderErr: Label 'You cannot insert a purchase line without a purchase header.';
MustSpecifyErr: Label 'You must either specify %1 or %2.', Comment = '%1 = Field Caption; %2 = Field Caption';
DifferentNonDedVATRatesSameVATIdentifierErr: Label 'You cannot set different Non-Deductible VAT % for the combinations of business and product groups with the same VAT identifier.\The following combination with the same VAT identifier has different Non-Deductible VAT %: business group %1, product group %2', Comment = '%1 = VAT business posting group code, %2 = VAT product posting group code';

protected var
Currency: Record Currency;
Expand Down Expand Up @@ -10304,6 +10306,26 @@ table 39 "Purchase Line"
exit("Matched Inv./Cr. Memo Lines" > 0);
end;

local procedure CheckNonDedVATPctConsistencyForZeroLine()
var
PurchLine: Record "Purchase Line";
begin
if "Non-Deductible VAT %" <> 0 then
exit;
if "VAT Identifier" = '' then
exit;
if not NonDeductibleVAT.IsNonDeductibleVATEnabled() then
exit;

PurchLine.SetRange("Document Type", "Document Type");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

CheckNonDedVATPctConsistencyForZeroLine() only reads "VAT Bus. Posting Group" and "VAT Prod. Posting Group", but its FindFirst() on the wide "Purchase Line" table does not call SetLoadFields(), so each validation loads a full row just to build the error text. Add SetLoadFields("VAT Bus. Posting Group", "VAT Prod. Posting Group") before the read.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

PurchLine.SetRange("Document No.", "Document No.");
PurchLine.SetFilter("Line No.", '<>%1', "Line No.");
PurchLine.SetRange("VAT Identifier", "VAT Identifier");
PurchLine.SetFilter("Non-Deductible VAT %", '<>%1', "Non-Deductible VAT %");
if PurchLine.FindFirst() then
Error(DifferentNonDedVATRatesSameVATIdentifierErr, PurchLine."VAT Bus. Posting Group", PurchLine."VAT Prod. Posting Group");
end;

local procedure CheckCorrectiveCreditMemoQtyIncrease(xPurchaseLine: Record "Purchase Line")
begin
if not ("Copied From Posted Doc." and IsCreditDocType()) then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3688,6 +3688,7 @@ table 39 "Purchase Line"
begin
NonDeductibleVAT.CheckPrepmtWithNonDeductubleVATInPurchaseLine(Rec);
NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed(Rec);
CheckNonDedVATPctConsistencyForZeroLine();
UpdateAmounts();
end;
}
Expand Down Expand Up @@ -4293,6 +4294,7 @@ table 39 "Purchase Line"
InvoiceOrOrderDocTypeErr: Label '%1 must be either %2 or %3.', Comment = '%1 - Document Type; %2, %3 - Purchase Document Type, Invoice or Order';
CannotInsertPurchLineWithoutHeaderErr: Label 'You cannot insert a purchase line without a purchase header.';
MustSpecifyErr: Label 'You must either specify %1 or %2.', Comment = '%1 = Field Caption; %2 = Field Caption';
DifferentNonDedVATRatesSameVATIdentifierErr: Label 'You cannot set different Non-Deductible VAT % for the combinations of business and product groups with the same VAT identifier.\The following combination with the same VAT identifier has different Non-Deductible VAT %: business group %1, product group %2', Comment = '%1 = VAT business posting group code, %2 = VAT product posting group code';

protected var
Currency: Record Currency;
Expand Down Expand Up @@ -10303,6 +10305,26 @@ table 39 "Purchase Line"
exit("Matched Inv./Cr. Memo Lines" > 0);
end;

local procedure CheckNonDedVATPctConsistencyForZeroLine()
var
PurchLine: Record "Purchase Line";
begin
if "Non-Deductible VAT %" <> 0 then
exit;
if "VAT Identifier" = '' then
exit;
if not NonDeductibleVAT.IsNonDeductibleVATEnabled() then
exit;

PurchLine.SetRange("Document Type", "Document Type");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

CheckNonDedVATPctConsistencyForZeroLine() only reads "VAT Bus. Posting Group" and "VAT Prod. Posting Group", but its FindFirst() on the wide "Purchase Line" table does not call SetLoadFields(), so each validation loads a full row just to build the error text. Add SetLoadFields("VAT Bus. Posting Group", "VAT Prod. Posting Group") before the read.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

PurchLine.SetRange("Document No.", "Document No.");
PurchLine.SetFilter("Line No.", '<>%1', "Line No.");
PurchLine.SetRange("VAT Identifier", "VAT Identifier");
PurchLine.SetFilter("Non-Deductible VAT %", '<>%1', "Non-Deductible VAT %");
if PurchLine.FindFirst() then
Error(DifferentNonDedVATRatesSameVATIdentifierErr, PurchLine."VAT Bus. Posting Group", PurchLine."VAT Prod. Posting Group");
end;

local procedure CheckCorrectiveCreditMemoQtyIncrease(xPurchaseLine: Record "Purchase Line")
begin
if not ("Copied From Posted Doc." and IsCreditDocType()) then
Expand Down
22 changes: 22 additions & 0 deletions src/Layers/ES/BaseApp/Purchases/Document/PurchaseLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -3692,6 +3692,7 @@ table 39 "Purchase Line"
begin
NonDeductibleVAT.CheckPrepmtWithNonDeductubleVATInPurchaseLine(Rec);
NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed(Rec);
CheckNonDedVATPctConsistencyForZeroLine();
UpdateAmounts();
end;
}
Expand Down Expand Up @@ -4299,6 +4300,7 @@ table 39 "Purchase Line"
InvoiceOrOrderDocTypeErr: Label '%1 must be either %2 or %3.', Comment = '%1 - Document Type; %2, %3 - Purchase Document Type, Invoice or Order';
CannotInsertPurchLineWithoutHeaderErr: Label 'You cannot insert a purchase line without a purchase header.';
MustSpecifyErr: Label 'You must either specify %1 or %2.', Comment = '%1 = Field Caption; %2 = Field Caption';
DifferentNonDedVATRatesSameVATIdentifierErr: Label 'You cannot set different Non-Deductible VAT % for the combinations of business and product groups with the same VAT identifier.\The following combination with the same VAT identifier has different Non-Deductible VAT %: business group %1, product group %2', Comment = '%1 = VAT business posting group code, %2 = VAT product posting group code';

protected var
Currency: Record Currency;
Expand Down Expand Up @@ -10327,6 +10329,26 @@ table 39 "Purchase Line"
exit("Matched Inv./Cr. Memo Lines" > 0);
end;

local procedure CheckNonDedVATPctConsistencyForZeroLine()
var
PurchLine: Record "Purchase Line";
begin
if "Non-Deductible VAT %" <> 0 then
exit;
if "VAT Identifier" = '' then
exit;
if not NonDeductibleVAT.IsNonDeductibleVATEnabled() then
exit;

PurchLine.SetRange("Document Type", "Document Type");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

CheckNonDedVATPctConsistencyForZeroLine() only reads "VAT Bus. Posting Group" and "VAT Prod. Posting Group", but its FindFirst() on the wide "Purchase Line" table does not call SetLoadFields(), so each validation loads a full row just to build the error text. Add SetLoadFields("VAT Bus. Posting Group", "VAT Prod. Posting Group") before the read.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

PurchLine.SetRange("Document No.", "Document No.");
PurchLine.SetFilter("Line No.", '<>%1', "Line No.");
PurchLine.SetRange("VAT Identifier", "VAT Identifier");
PurchLine.SetFilter("Non-Deductible VAT %", '<>%1', "Non-Deductible VAT %");
if PurchLine.FindFirst() then
Error(DifferentNonDedVATRatesSameVATIdentifierErr, PurchLine."VAT Bus. Posting Group", PurchLine."VAT Prod. Posting Group");
end;

local procedure CheckCorrectiveCreditMemoQtyIncrease(xPurchaseLine: Record "Purchase Line")
begin
if not ("Copied From Posted Doc." and IsCreditDocType()) then
Expand Down
22 changes: 22 additions & 0 deletions src/Layers/FI/BaseApp/Purchases/Document/PurchaseLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -3689,6 +3689,7 @@ table 39 "Purchase Line"
begin
NonDeductibleVAT.CheckPrepmtWithNonDeductubleVATInPurchaseLine(Rec);
NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed(Rec);
CheckNonDedVATPctConsistencyForZeroLine();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

This adds a new error path to the shipped OnValidate trigger of field 6200 "Non-Deductible VAT %": existing extensions, integrations, or data-migration code that previously called Validate("Non-Deductible VAT %", 0) successfully can now fail when another line on the same document has the same VAT Identifier with a different percentage. Preserve the released field-trigger behavior or move the stricter consistency check behind a compatible opt-in path; BCQuality has no knowledge-backed rule for trigger-behavior breaks yet, so this functional breaking change can only be emitted as an agent finding.

The same issue exists in these regional copies — apply the equivalent fix in each:

  • src/Layers/SE/BaseApp/Purchases/Document/PurchaseLine.Table.al:3692 (SE)

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

UpdateAmounts();
end;
}
Expand Down Expand Up @@ -4286,6 +4287,7 @@ table 39 "Purchase Line"
InvoiceOrOrderDocTypeErr: Label '%1 must be either %2 or %3.', Comment = '%1 - Document Type; %2, %3 - Purchase Document Type, Invoice or Order';
CannotInsertPurchLineWithoutHeaderErr: Label 'You cannot insert a purchase line without a purchase header.';
MustSpecifyErr: Label 'You must either specify %1 or %2.', Comment = '%1 = Field Caption; %2 = Field Caption';
DifferentNonDedVATRatesSameVATIdentifierErr: Label 'You cannot set different Non-Deductible VAT % for the combinations of business and product groups with the same VAT identifier.\The following combination with the same VAT identifier has different Non-Deductible VAT %: business group %1, product group %2', Comment = '%1 = VAT business posting group code, %2 = VAT product posting group code';

protected var
Currency: Record Currency;
Expand Down Expand Up @@ -10296,6 +10298,26 @@ table 39 "Purchase Line"
exit("Matched Inv./Cr. Memo Lines" > 0);
end;

local procedure CheckNonDedVATPctConsistencyForZeroLine()
var
PurchLine: Record "Purchase Line";
begin
if "Non-Deductible VAT %" <> 0 then
exit;
if "VAT Identifier" = '' then
exit;
if not NonDeductibleVAT.IsNonDeductibleVATEnabled() then
exit;

PurchLine.SetRange("Document Type", "Document Type");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

CheckNonDedVATPctConsistencyForZeroLine() only reads "VAT Bus. Posting Group" and "VAT Prod. Posting Group", but its FindFirst() on the wide "Purchase Line" table does not call SetLoadFields(), so each validation loads a full row just to build the error text. Add SetLoadFields("VAT Bus. Posting Group", "VAT Prod. Posting Group") before the read.

Knowledge:

The same issue exists in these regional copies — apply the equivalent fix in each:

  • src/Layers/SE/BaseApp/Purchases/Document/PurchaseLine.Table.al:10312 (SE)

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

PurchLine.SetRange("Document No.", "Document No.");
PurchLine.SetFilter("Line No.", '<>%1', "Line No.");
PurchLine.SetRange("VAT Identifier", "VAT Identifier");
PurchLine.SetFilter("Non-Deductible VAT %", '<>%1', "Non-Deductible VAT %");
if PurchLine.FindFirst() then
Error(DifferentNonDedVATRatesSameVATIdentifierErr, PurchLine."VAT Bus. Posting Group", PurchLine."VAT Prod. Posting Group");
end;

local procedure CheckCorrectiveCreditMemoQtyIncrease(xPurchaseLine: Record "Purchase Line")
begin
if not ("Copied From Posted Doc." and IsCreditDocType()) then
Expand Down
22 changes: 22 additions & 0 deletions src/Layers/GB/BaseApp/Purchases/Document/PurchaseLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -3705,6 +3705,7 @@ table 39 "Purchase Line"
begin
NonDeductibleVAT.CheckPrepmtWithNonDeductubleVATInPurchaseLine(Rec);
NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed(Rec);
CheckNonDedVATPctConsistencyForZeroLine();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

This adds a new error path to the shipped OnValidate trigger of field 6200 "Non-Deductible VAT %": existing extensions, integrations, or data-migration code that previously called Validate("Non-Deductible VAT %", 0) successfully can now fail when another line on the same document has the same VAT Identifier with a different percentage. Preserve the released field-trigger behavior or move the stricter consistency check behind a compatible opt-in path; BCQuality has no knowledge-backed rule for trigger-behavior breaks yet, so this functional breaking change can only be emitted as an agent finding.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

UpdateAmounts();
end;
}
Expand Down Expand Up @@ -4318,6 +4319,7 @@ table 39 "Purchase Line"
InvoiceOrOrderDocTypeErr: Label '%1 must be either %2 or %3.', Comment = '%1 - Document Type; %2, %3 - Purchase Document Type, Invoice or Order';
CannotInsertPurchLineWithoutHeaderErr: Label 'You cannot insert a purchase line without a purchase header.';
MustSpecifyErr: Label 'You must either specify %1 or %2.', Comment = '%1 = Field Caption; %2 = Field Caption';
DifferentNonDedVATRatesSameVATIdentifierErr: Label 'You cannot set different Non-Deductible VAT % for the combinations of business and product groups with the same VAT identifier.\The following combination with the same VAT identifier has different Non-Deductible VAT %: business group %1, product group %2', Comment = '%1 = VAT business posting group code, %2 = VAT product posting group code';

protected var
Currency: Record Currency;
Expand Down Expand Up @@ -10347,6 +10349,26 @@ table 39 "Purchase Line"
exit("Matched Inv./Cr. Memo Lines" > 0);
end;

local procedure CheckNonDedVATPctConsistencyForZeroLine()
var
PurchLine: Record "Purchase Line";
begin
if "Non-Deductible VAT %" <> 0 then
exit;
if "VAT Identifier" = '' then
exit;
if not NonDeductibleVAT.IsNonDeductibleVATEnabled() then
exit;

PurchLine.SetRange("Document Type", "Document Type");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

CheckNonDedVATPctConsistencyForZeroLine() only reads "VAT Bus. Posting Group" and "VAT Prod. Posting Group", but its FindFirst() on the wide "Purchase Line" table does not call SetLoadFields(), so each validation loads a full row just to build the error text. Add SetLoadFields("VAT Bus. Posting Group", "VAT Prod. Posting Group") before the read.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

PurchLine.SetRange("Document No.", "Document No.");
PurchLine.SetFilter("Line No.", '<>%1', "Line No.");
PurchLine.SetRange("VAT Identifier", "VAT Identifier");
PurchLine.SetFilter("Non-Deductible VAT %", '<>%1', "Non-Deductible VAT %");
if PurchLine.FindFirst() then
Error(DifferentNonDedVATRatesSameVATIdentifierErr, PurchLine."VAT Bus. Posting Group", PurchLine."VAT Prod. Posting Group");
end;

local procedure CheckCorrectiveCreditMemoQtyIncrease(xPurchaseLine: Record "Purchase Line")
begin
if not ("Copied From Posted Doc." and IsCreditDocType()) then
Expand Down
22 changes: 22 additions & 0 deletions src/Layers/IT/BaseApp/Purchases/Document/PurchaseLine.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -3743,6 +3743,7 @@ table 39 "Purchase Line"
begin
NonDeductibleVAT.CheckPrepmtWithNonDeductubleVATInPurchaseLine(Rec);
NonDeductibleVAT.CheckNonDeductibleVATPctIsAllowed(Rec);
CheckNonDedVATPctConsistencyForZeroLine();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

This adds a new error path to the shipped OnValidate trigger of field 6200 "Non-Deductible VAT %": existing extensions, integrations, or data-migration code that previously called Validate("Non-Deductible VAT %", 0) successfully can now fail when another line on the same document has the same VAT Identifier with a different percentage. Preserve the released field-trigger behavior or move the stricter consistency check behind a compatible opt-in path; BCQuality has no knowledge-backed rule for trigger-behavior breaks yet, so this functional breaking change can only be emitted as an agent finding.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

UpdateAmounts();
end;
}
Expand Down Expand Up @@ -4544,6 +4545,7 @@ table 39 "Purchase Line"
InvoiceOrOrderDocTypeErr: Label '%1 must be either %2 or %3.', Comment = '%1 - Document Type; %2, %3 - Purchase Document Type, Invoice or Order';
CannotInsertPurchLineWithoutHeaderErr: Label 'You cannot insert a purchase line without a purchase header.';
MustSpecifyErr: Label 'You must either specify %1 or %2.', Comment = '%1 = Field Caption; %2 = Field Caption';
DifferentNonDedVATRatesSameVATIdentifierErr: Label 'You cannot set different Non-Deductible VAT % for the combinations of business and product groups with the same VAT identifier.\The following combination with the same VAT identifier has different Non-Deductible VAT %: business group %1, product group %2', Comment = '%1 = VAT business posting group code, %2 = VAT product posting group code';

protected var
Currency: Record Currency;
Expand Down Expand Up @@ -10582,6 +10584,26 @@ table 39 "Purchase Line"
exit("Matched Inv./Cr. Memo Lines" > 0);
end;

local procedure CheckNonDedVATPctConsistencyForZeroLine()
var
PurchLine: Record "Purchase Line";
begin
if "Non-Deductible VAT %" <> 0 then
exit;
if "VAT Identifier" = '' then
exit;
if not NonDeductibleVAT.IsNonDeductibleVATEnabled() then
exit;

PurchLine.SetRange("Document Type", "Document Type");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

CheckNonDedVATPctConsistencyForZeroLine() only reads "VAT Bus. Posting Group" and "VAT Prod. Posting Group", but its FindFirst() on the wide "Purchase Line" table does not call SetLoadFields(), so each validation loads a full row just to build the error text. Add SetLoadFields("VAT Bus. Posting Group", "VAT Prod. Posting Group") before the read.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4

PurchLine.SetRange("Document No.", "Document No.");
PurchLine.SetFilter("Line No.", '<>%1', "Line No.");
PurchLine.SetRange("VAT Identifier", "VAT Identifier");
PurchLine.SetFilter("Non-Deductible VAT %", '<>%1', "Non-Deductible VAT %");
if PurchLine.FindFirst() then
Error(DifferentNonDedVATRatesSameVATIdentifierErr, PurchLine."VAT Bus. Posting Group", PurchLine."VAT Prod. Posting Group");
end;

local procedure CheckCorrectiveCreditMemoQtyIncrease(xPurchaseLine: Record "Purchase Line")
begin
if not ("Copied From Posted Doc." and IsCreditDocType()) then
Expand Down
Loading
Loading