-
Notifications
You must be signed in to change notification settings - Fork 441
Slice 611704: With Autoincrement Tax Transaction Value ID field changed to BigInteger to prevent IDENTITY exhaustion #10510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ namespace Microsoft.Finance.TaxEngine.TaxTypeHandler; | |
| using Microsoft.Finance.Currency; | ||
| using Microsoft.Finance.GeneralLedger.Journal; | ||
| using Microsoft.Finance.TaxEngine.Core; | ||
| using Microsoft.Foundation.NoSeries; | ||
| using Microsoft.Inventory.Transfer; | ||
| using Microsoft.Purchases.Archive; | ||
| using Microsoft.Purchases.Document; | ||
|
|
@@ -101,12 +102,16 @@ table 20261 "Tax Transaction Value" | |
| DataClassification = EndUserIdentifiableInformation; | ||
| Caption = 'Visible on Interface'; | ||
| } | ||
| field(18; "ID"; Integer) | ||
| #pragma warning disable AS0146 | ||
| #pragma warning disable AS0041 | ||
| field(18; "ID"; BigInteger) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Table 20261 field 18 "ID" keeps Agent judgement — not directly backed by a BCQuality knowledge article. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
||
| { | ||
| DataClassification = SystemMetadata; | ||
| Caption = 'ID'; | ||
| AutoIncrement = true; | ||
| } | ||
| #pragma warning restore AS0041 | ||
| #pragma warning restore AS0146 | ||
| field(19; "Tax Type"; Code[20]) | ||
| { | ||
| DataClassification = EndUserIdentifiableInformation; | ||
|
|
@@ -153,6 +158,17 @@ table 20261 "Tax Transaction Value" | |
| { | ||
| } | ||
| } | ||
|
|
||
| trigger OnInsert() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
||
| var | ||
| SequenceNoMgt: Codeunit "Sequence No. Mgt."; | ||
| begin | ||
| if Rec.IsTemporary() then | ||
| exit; | ||
|
|
||
| Rec.ID := SequenceNoMgt.GetNextSeqNoBigInt(Database::"Tax Transaction Value"); | ||
| end; | ||
|
|
||
| procedure GetAttributeColumName(): Text | ||
| var | ||
| TaxAttribute: Record "Tax Attribute"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,6 +139,65 @@ codeunit 9500 "Sequence No. Mgt." | |
| exit(CurrSeqNo); | ||
| end; | ||
|
|
||
| /// <summary> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
||
| /// Returns the next NumberSequence value for a given table ID as a BigInteger. | ||
| /// Use for tables whose primary key number field is a BigInteger. If the sequence does not exist, it will be created. | ||
| /// </summary> | ||
| /// <param name="TableNo">The ID of the table being checked</param> | ||
| procedure GetNextSeqNoBigInt(TableNo: Integer): BigInteger | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new public BigInteger sequence APIs ( Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
||
| var | ||
| NewSeqNo: BigInteger; | ||
| PreviewMode: Boolean; | ||
| begin | ||
| PreviewMode := IsPreviewMode(); // Only call once to minimize sql calls during preview. | ||
| ValidateSeqNoBigInt(TableNo); | ||
| if TryGetNextNoBigInt(PreviewMode, TableNo, NewSeqNo) then | ||
| exit(NewSeqNo); | ||
| ClearLastError(); | ||
| CreateNewTableSequence(PreviewMode, TableNo); | ||
| TryGetNextNoBigInt(PreviewMode, TableNo, NewSeqNo); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This standalone call ignores the Boolean result of Suggested fix (apply manually — could not be anchored as a one-click suggestion): if not TryGetNextNoBigInt(PreviewMode, TableNo, NewSeqNo) then
Error(GetLastErrorText());Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
||
| exit(NewSeqNo); | ||
| end; | ||
|
|
||
| /// <summary> | ||
| /// Returns the current NumberSequence value for a given table ID as a BigInteger. | ||
| /// if the sequence does not exist, it will be created. | ||
| /// </summary> | ||
| /// <param name="TableNo">The ID of the table being checked</param> | ||
| procedure GetCurrentSeqNoBigInt(TableNo: Integer): BigInteger | ||
| var | ||
| CurrSeqNo: BigInteger; | ||
| PreviewMode: Boolean; | ||
| begin | ||
| PreviewMode := IsPreviewMode(); // Only call once to minimize sql calls during preview. | ||
| if TryGetCurrentNoBigInt(PreviewMode, TableNo, CurrSeqNo) then | ||
| exit(CurrSeqNo); | ||
| ClearLastError(); | ||
| CreateNewTableSequence(PreviewMode, TableNo); | ||
| TryGetCurrentNoBigInt(PreviewMode, TableNo, CurrSeqNo); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This standalone call ignores the Boolean result of Suggested fix (apply manually — could not be anchored as a one-click suggestion): if not TryGetCurrentNoBigInt(PreviewMode, TableNo, CurrSeqNo) then
Error(GetLastErrorText());Knowledge: 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4 |
||
| exit(CurrSeqNo); | ||
| end; | ||
|
|
||
| /// <summary> | ||
| /// BigInteger-safe variant of ValidateSeqNo. Ensures the NumberSequence is not behind the last entry in the table. | ||
| /// </summary> | ||
| /// <param name="TableNo">The ID of the table being checked</param> | ||
| procedure ValidateSeqNoBigInt(TableNo: Integer) | ||
| var | ||
| LastEntryNo: BigInteger; | ||
| begin | ||
| if IsPreviewMode() then | ||
| exit; | ||
| if LastSeqNoChecked.Contains(TableNo) then | ||
| exit; | ||
|
|
||
| LastEntryNo := GetLastEntryNoFromTable(TableNo, false); | ||
| if GetCurrentSeqNoBigInt(TableNo) < LastEntryNo then | ||
| RebaseSeqNo(TableNo); | ||
|
|
||
| LastSeqNoChecked.Add(TableNo); | ||
| end; | ||
|
|
||
| /// <summary> | ||
| /// Ensures that the NumberSequence is not behind the last entry in the table. | ||
| /// if the sequence does not exist, it will be created. | ||
|
|
@@ -187,6 +246,18 @@ codeunit 9500 "Sequence No. Mgt." | |
| CurrSeqNo := NumberSequence.Current(GetTableSequenceName(PreviewMode, TableNo)); | ||
| end; | ||
|
|
||
| [TryFunction] | ||
| local procedure TryGetNextNoBigInt(PreviewMode: Boolean; TableNo: Integer; var NewSeqNo: BigInteger) | ||
| begin | ||
| NewSeqNo := NumberSequence.Next(GetTableSequenceName(PreviewMode, TableNo)); | ||
| end; | ||
|
|
||
| [TryFunction] | ||
| local procedure TryGetCurrentNoBigInt(PreviewMode: Boolean; TableNo: Integer; var CurrSeqNo: BigInteger) | ||
| begin | ||
| CurrSeqNo := NumberSequence.Current(GetTableSequenceName(PreviewMode, TableNo)); | ||
| end; | ||
|
|
||
| /// <summary> | ||
| /// Restarts or recreates the NumberSequence for the specified Table ID. | ||
| /// </summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Table 20261 "Tax Transaction Value" field 18 "ID" changes type from Integer to BigInteger in place (kept
AutoIncrement = true), wrapped in#pragma warning disable AS0146/AS0041to suppress the analyzer rules that specifically guard against changing a published field's type/AutoIncrement semantics. Suppressing those analyzer warnings rather than following the obsoletion lifecycle (new field + Obsolete on the old one) is a real breaking-change risk for any extension compiled against or persisting this field as Integer.Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.35.4