From 93ece28efdb9569ef68345439971de6c6a5bc810 Mon Sep 17 00:00:00 2001 From: Tabrez Ajaz Date: Fri, 21 Aug 2026 18:35:52 +0530 Subject: [PATCH] Commit as suggested. --- .../codeunit/TaxDocumentGLPosting.Codeunit.al | 3 +- .../codeunit/TaxPostingBufferMgmt.Codeunit.al | 2 +- .../table/TaxTransactionValue.Table.al | 18 ++++- .../codeunit/TaxRateComputation.Codeunit.al | 2 +- .../NoSeries/SequenceNoMgt.Codeunit.al | 71 +++++++++++++++++++ 5 files changed, 91 insertions(+), 5 deletions(-) diff --git a/src/Apps/W1/INTaxEngine/app/TaxEngine-PostingHandler/src/PostingManagement/codeunit/TaxDocumentGLPosting.Codeunit.al b/src/Apps/W1/INTaxEngine/app/TaxEngine-PostingHandler/src/PostingManagement/codeunit/TaxDocumentGLPosting.Codeunit.al index 36a8534759e..6e772eea05b 100644 --- a/src/Apps/W1/INTaxEngine/app/TaxEngine-PostingHandler/src/PostingManagement/codeunit/TaxDocumentGLPosting.Codeunit.al +++ b/src/Apps/W1/INTaxEngine/app/TaxEngine-PostingHandler/src/PostingManagement/codeunit/TaxDocumentGLPosting.Codeunit.al @@ -70,8 +70,7 @@ codeunit 20341 "Tax Document GL Posting" ToTaxTransactionValue.Init(); ToTaxTransactionValue := FromTaxTransactionValue; ToTaxTransactionValue."Tax Record ID" := ToRecID; - ToTaxTransactionValue.ID := 0; - ToTaxTransactionValue.Insert(); + ToTaxTransactionValue.Insert(true); until FromTaxTransactionValue.Next() = 0; end; diff --git a/src/Apps/W1/INTaxEngine/app/TaxEngine-PostingHandler/src/PostingManagement/codeunit/TaxPostingBufferMgmt.Codeunit.al b/src/Apps/W1/INTaxEngine/app/TaxEngine-PostingHandler/src/PostingManagement/codeunit/TaxPostingBufferMgmt.Codeunit.al index 74b491eb069..2ff40049d8b 100644 --- a/src/Apps/W1/INTaxEngine/app/TaxEngine-PostingHandler/src/PostingManagement/codeunit/TaxPostingBufferMgmt.Codeunit.al +++ b/src/Apps/W1/INTaxEngine/app/TaxEngine-PostingHandler/src/PostingManagement/codeunit/TaxPostingBufferMgmt.Codeunit.al @@ -317,7 +317,7 @@ codeunit 20343 "Tax Posting Buffer Mgmt." InvoiceQty: Decimal) var TaxTransactionValue: Record "Tax Transaction Value"; - NextID: Integer; + NextID: BigInteger; begin TempTransactionValue.Reset(); NextID := TempTransactionValue.Count(); diff --git a/src/Apps/W1/INTaxEngine/app/TaxEngine-TaxTypeHandler/src/TransactionValue/table/TaxTransactionValue.Table.al b/src/Apps/W1/INTaxEngine/app/TaxEngine-TaxTypeHandler/src/TransactionValue/table/TaxTransactionValue.Table.al index 734dc68f247..527748dfbaf 100644 --- a/src/Apps/W1/INTaxEngine/app/TaxEngine-TaxTypeHandler/src/TransactionValue/table/TaxTransactionValue.Table.al +++ b/src/Apps/W1/INTaxEngine/app/TaxEngine-TaxTypeHandler/src/TransactionValue/table/TaxTransactionValue.Table.al @@ -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) { 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() + 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"; diff --git a/src/Apps/W1/INTaxEngine/app/TaxEngine-UseCaseBuilder/src/UseCase/codeunit/TaxRateComputation.Codeunit.al b/src/Apps/W1/INTaxEngine/app/TaxEngine-UseCaseBuilder/src/UseCase/codeunit/TaxRateComputation.Codeunit.al index b1cd32c5417..d80146c18ca 100644 --- a/src/Apps/W1/INTaxEngine/app/TaxEngine-UseCaseBuilder/src/UseCase/codeunit/TaxRateComputation.Codeunit.al +++ b/src/Apps/W1/INTaxEngine/app/TaxEngine-UseCaseBuilder/src/UseCase/codeunit/TaxRateComputation.Codeunit.al @@ -204,7 +204,7 @@ codeunit 20291 "Tax Rate Computation" TaxTransactionValue."Value Type" := TransactionValueType; TaxTransactionValue."Tax Type" := TaxType; TaxTransactionValue."Value ID" := ID; - TaxTransactionValue.Insert(); + TaxTransactionValue.Insert(true); end; local procedure ModifyTaxTransactionValue( diff --git a/src/Layers/W1/BaseApp/Foundation/NoSeries/SequenceNoMgt.Codeunit.al b/src/Layers/W1/BaseApp/Foundation/NoSeries/SequenceNoMgt.Codeunit.al index b24db5874b1..11d27682ab3 100644 --- a/src/Layers/W1/BaseApp/Foundation/NoSeries/SequenceNoMgt.Codeunit.al +++ b/src/Layers/W1/BaseApp/Foundation/NoSeries/SequenceNoMgt.Codeunit.al @@ -139,6 +139,65 @@ codeunit 9500 "Sequence No. Mgt." exit(CurrSeqNo); end; + /// + /// 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. + /// + /// The ID of the table being checked + procedure GetNextSeqNoBigInt(TableNo: Integer): BigInteger + 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); + exit(NewSeqNo); + end; + + /// + /// Returns the current NumberSequence value for a given table ID as a BigInteger. + /// if the sequence does not exist, it will be created. + /// + /// The ID of the table being checked + 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); + exit(CurrSeqNo); + end; + + /// + /// BigInteger-safe variant of ValidateSeqNo. Ensures the NumberSequence is not behind the last entry in the table. + /// + /// The ID of the table being checked + 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; + /// /// 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; + /// /// Restarts or recreates the NumberSequence for the specified Table ID. ///