Skip to content

[Main]ERM Purchase Payables.UnreliazedGainLossEntrieAreClearWhenUsingMultiplePostingGroups fails (G/L account not balanced)- #13241 - #14574

Open
sanjmaurya wants to merge 3 commits into
mainfrom
bugs/Bug-647653-Main-PurchasePayablesUnreliazedGainLossEntrieAreClearWhenUsingNew1
Open

sanjmaurya wants to merge 3 commits into
mainfrom
bugs/Bug-647653-Main-PurchasePayablesUnreliazedGainLossEntrieAreClearWhenUsingNew1

Conversation

@sanjmaurya

@sanjmaurya sanjmaurya commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Bug 647653: [ALL-E]ERM Purchase Payables.UnreliazedGainLossEntrieAreClearWhenUsingMultiplePostingGroups fails (G/L account not balanced)

Fixes AB#647653

Issue: The UnreliazedGainLossEntrieAreClearWhenUsingMultiplePostingGroups test failed when applying a payment that used a different vendor posting group from the purchase invoice.

Cause: The test setup allowed the vendor posting group change from group 1 to group 2, but did not define the reverse alternate posting-group relationship. The application flow needs that relationship when matching the payment and invoice.

Solution: Added the reverse alternate vendor posting-group mapping, from group 2 to group 1. The test now passes with both directions configured.

@github-actions github-actions Bot added the Team: Finance GitHub request for Finance area label Nov 26, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Nov 26, 2026
@sanjmaurya
sanjmaurya marked this pull request as ready for review November 26, 2026 07:23
@sanjmaurya
sanjmaurya requested a review from a team as a code owner November 26, 2026 07:23
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Accept with Suggestions

What this PR does

Changes vendor application posting so unrealized gain/loss reversals can move to the original payables account when the aggregate uses another account. It also clears the full detailed-entry buffer and adds gain, loss, and unapply/reapply scenarios in four test copies.

The transfer posts equal and opposite amounts only when the accounts differ. Unapplication collects reversing entries for the same transfer step, and the final Reset() prevents cleanup from keeping the realized gain/loss filter. The new tests assert account balances, but their inputs bypass the helper's actual transfer postings.

Problem-solution fit

Fit: Partial

The posting changes target the reported control-account imbalance. The setup-only explanation does not match the production changes, and direct coverage of the new transfer path is missing.

Suggestions

S1 (🟠 Moderate): Explain the actual production posting changes
Describe the production transfer, unapply, and buffer-cleanup changes. The reverse alternate posting-group mapping is already present, so the current setup-only summary does not match this change.

S2 (🟠 Moderate): Exercise the new payables transfer branch
Add apply/unapply coverage with a 75-LCY payment at the original rate after revaluation. The current 90-LCY cases select the invoice account for both sides, so they never exercise the new two-account transfer.

Risk assessment and necessity

Risk: Financially sensitive: codeunit 12 changes payables account distribution during application and unapplication in 11 BaseApp copies. The account and amount guards limit the new postings, with no public signature or table changes. The transfer branch still needs direct regression coverage; AL builds and tests were not run.

Necessity: Without a correction, revalued invoices applied across vendor posting groups can leave control-account balances after full settlement. A focused posting and buffer-cleanup fix is justified.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=14574 round=1 by=alexei-dobriansky at=2026-11-26T08:13:37Z lastSha=0ffa93e020ac7d45b053fa986671bdebaab77be6 reviewKey=33c1e02160fb26f88f6005017261a1ebbaa7762e4daff41828c863360f1fcfba suggestions=S1@35142110,S2@ad5bcc8e

exit;

// Keep the unrealized reversal on the payable account that was originally revalued.
UnrealizedPayablesAccountNo := GetVendDtldCVLedgEntryBufferAccNo(GenJournalLine, DetailedCVLedgEntryBuffer);

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{🟠\ High\ Severity\ —\ Performance}$

The new unrealized gain/loss loop calls GetVendDtldCVLedgEntryBufferAccNo for every buffer row. That helper performs primary-key Gets on Vendor Ledger Entry and Vendor Posting Group, creating an unbounded per-row lookup pattern in the vendor posting hot path. Resolve the posting account with a set-based join or a correctly scoped reuse strategy before iterating, while preserving distinct posting-group results.

Knowledge:

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

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 2

Recommendation: Accept with Suggestions

What this PR does

Since round 1, the change adds explicit length bounds to test arguments in CZ, FI, GB, and W1 and removes a setup-helper call that is not available in FI. Production posting code is unchanged in this round.

These corrections leave the payment amounts, exchange rates, application flow, and balance assertions unchanged. The full change still targets unrealized gain/loss reversals across vendor posting groups, but the explanation and direct two-account transfer coverage remain incomplete.

Problem-solution fit

Fit: Partial

The posting changes target the residual payables balance. The setup-only explanation still omits those changes, and the tests do not directly cover the unequal-account transfer.

Status of previous suggestions
ID Title Status Author response
S1 Explain the actual production posting changes Not addressed No reply. The summary still describes only reverse mapping, not the production transfer, unapply, and buffer-cleanup changes.
S2 Exercise the new payables transfer branch Not addressed No reply. The helper arguments 80/70 set the revaluation rate, not the payment; each helper case still pays 90 LCY and lacks the original-rate, different-account transfer case.
New observations (commits since round 1)

None - the new commit only corrects test setup and argument lengths.

Risk assessment and necessity

Risk: The latest changes affect tests only. The full change remains financially sensitive: vendor application and unapplication posting changes span 11 BaseApp copies, and the unequal-account transfer branch still lacks direct coverage. Public signatures and customer posting logic are unchanged. AL builds and tests were not run.

Necessity: Without a posting correction, revalued invoices applied across different vendor posting groups can leave control-account balances after settlement. A focused correction is justified; the two existing suggestions remain open.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=14574 round=2 by=alexei-dobriansky at=2026-11-26T14:47:22.7538891Z lastSha=2c29d015e084b7c42187774892718958bc5dadea reviewKey=4b6b7781fbd325e92b6ffeec2191864a676c1604b333b1d76b6e70450e051fcd suggestions=S1@35142110:notaddressed,S2@ad5bcc8e:notaddressed parentRound=1

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

@sanjmaurya sanjmaurya closed this Nov 30, 2026
DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

DetailedCVLedgEntryBuffer.SetFilter("Entry Type", '%1|%2', DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Gain", DetailedCVLedgEntryBuffer."Entry Type"::"Unrealized Loss");
if DetailedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLine, DetailedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnPostDtldVendLedgEntriesOnBeforeCreateGLEntriesForTotalAmounts can suppress this required posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

CreateGLEntriesForTotalAmountsUnapply(GenJournalLineToPost, TempDimensionPostingBuffer, PayablesAccountNo);
if TempUnrealizedCVLedgEntryBuffer.FindSet() then
repeat
PostUnrealizedVendGainLossTransfer(GenJournalLineToPost, TempUnrealizedCVLedgEntryBuffer, PayablesAccountNo);

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{🟠\ High\ Severity\ —\ Events}$

The newly added unrealized gain/loss transfer creates ledger entries inside the existing IsHandled guard, so a subscriber handling OnBeforeCreateGLEntriesForTotalAmountsUnapplyVendorV19 can suppress this required unapply posting operation. Keep the transfer outside the overridable guard or expose only a safe calculation to IsHandled.

Knowledge:

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

var
UnrealizedPayablesAccountNo: Code[20];
begin
if DetailedCVLedgEntryBuffer."Amount (LCY)" = 0 then

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\ —\ Finance}$

The new guard exits whenever the unrealized entry's LCY amount is zero, even when its additional-currency amount is nonzero. In additional-currency posting, this skips both transfer G/L entries and leaves the unrealized gain or loss on the wrong payables account. Use the same LCY-or-additional-currency nonzero condition used by the surrounding posting logic; the identical guard is present in all 11 localized GenJnlPostLine files.

Suggested fix (apply manually — could not be anchored as a one-click suggestion):

        if (DetailedCVLedgEntryBuffer."Amount (LCY)" = 0) and
           ((AddCurrencyCode = '') or (DetailedCVLedgEntryBuffer."Additional-Currency Amount" = 0))
        then
            exit;

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

This branch was successfully deployed

1 active deployment
triage — 2c29d015 Deployed Nov 30, 2026 by sanjmaurya via Classify team ownership #12340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team: Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants