[Main] [all-e]Unbalanced G/L Entries if you apply a Payment and a Posted Purchase Invoice having both different Posting Groups and using the "Applies-to Document No." on the line instead of using Apply Entries in the Spanish version.#8950
Conversation
Copilot PR ReviewIteration 14 · Outcome: completed Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Findings by domainFindings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).
Totals: 1 knowledge-backed · 0 agent findings. Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
Agentic PR Review - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThis PR narrows the ES-specific vendor application account override when a payment is applied through The change matches the root cause: the detailed buffer SuggestionsS1 - PR text overstates unapply coverage Risk assessment and necessityRisk: This is high-sensitivity posting code in the ES BaseApp vendor application path. The code change is narrow, adds no public API or event signature change, and does not depend on a new BaseApp publisher. W1 and other country BaseApp layers use the existing vendor ledger entry posting group path directly and do not have this ES Cartera special case, so the ES-only scope is appropriate. Necessity: The ADO bug is clear and important: applying a posted purchase invoice through
|
|
…dG/LEntriesIfyouApply-PaymentPostedPurchase
…dG/LEntriesIfyouApply-PaymentPostedPurchase
PostDtldVendLedgEntry was fixed in this PR to skip the payment's own Payables Account when the applied document (via "Applies-to Doc.No.") uses a different Vendor Posting Group, by adding IsApplnEntryForAppliedVendorDoc as an extra guard. PostDtldVendLedgEntryUnapply (lines 5645-5674) contains the exact same MultiplePostingGroups / Initial Document Type / Applies-to Doc. No. condition structure but was not updated with the same guard. If a payment applied this way is later unapplied, the unapply path will still resolve to the payment's own posting group's Payables Account instead of the applied invoice's, reintroducing the same G/L imbalance this PR fixes for the apply path — only during unapply. Given the underlying impact mirrors the bug this PR fixes (potentially major/blocker if it recurs), this concern should be verified and, if confirmed, promoted to a tracked fix (and ideally a knowledge-backed rule about keeping apply/unapply account-resolution logic symmetric) rather than left as an advisory-only agent finding. Recommendation:
Suggested fix (apply manually — could not be anchored as a one-click suggestion): if MultiplePostingGroups and (DetailedCVLedgEntryBuffer."Entry Type" = DetailedCVLedgEntryBuffer."Entry Type"::Application) then
if DetailedCVLedgEntryBuffer."Initial Document Type" = DetailedCVLedgEntryBuffer."Initial Document Type"::Bill then
AccNo := VendPostingGr."Payables Account"
else
if (GenJournalLine."Document Type" = GenJournalLine."Document Type"::Payment) and (GenJournalLine."Applies-to Doc. No." <> '') and (DetailedCVLedgEntryBuffer."Document Type" = DetailedCVLedgEntryBuffer."Document Type"::Payment) and
(not IsApplnEntryForAppliedVendorDoc(GenJournalLine, DetailedCVLedgEntryBuffer))
then
AccNo := VendPostingGr."Payables Account"
else
AccNo := GetVendDtldCVLedgEntryBufferAccNo(GenJournalLine, DetailedCVLedgEntryBuffer)
elseLine mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
…dG/LEntriesIfyouApply-PaymentPostedPurchase
…dG/LEntriesIfyouApply-PaymentPostedPurchase
Underlying impact would otherwise be major/blocker, capped to minor per agent-finding severity rules (no knowledge-file citation yet).GenJnlPostLine.Codeunit.al adds IsApplnEntryForAppliedVendorDoc(...) to PostDtldVendLedgEntry (the apply path, line ~5634) so an application posted via 'Applies-to Doc. No.' against a differently-posting-grouped document routes to the applied document's own Payables Account instead of the payment's. PostDtldVendLedgEntryUnapply — the sibling reversal procedure a few lines below (~5666) — still has the exact pre-fix condition without the new guard, so reversing (unapplying) such a payment will route the reversing G/L entry to the payment's posting-group Payables Account instead of the invoice's, re-introducing the same balance defect this PR fixes for apply. The new test (ApplyPmtToPostedPurchInvWithDifferentPostingGroupsViaAppliesToDocNo) only exercises apply and does not cover unapply, so this gap is untested. Recommendation:
Suggested fix (apply manually — could not be anchored as a one-click suggestion): if (GenJournalLine."Document Type" = GenJournalLine."Document Type"::Payment) and (GenJournalLine."Applies-to Doc. No." <> '') and (DetailedCVLedgEntryBuffer."Document Type" = DetailedCVLedgEntryBuffer."Document Type"::Payment) and
(not IsApplnEntryForAppliedVendorDoc(GenJournalLine, DetailedCVLedgEntryBuffer))
then
AccNo := VendPostingGr."Payables Account"
else
AccNo := GetVendDtldCVLedgEntryBufferAccNo(GenJournalLine, DetailedCVLedgEntryBuffer)Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
…dG/LEntriesIfyouApply-PaymentPostedPurchase
PostDtldVendLedgEntryUnapply (line 5645) still contains the exact pre-fix condition that PostDtldVendLedgEntry (line 5630) just had corrected: 'if (GenJournalLine."Document Type" = ...Payment) and (GenJournalLine."Applies-to Doc.No." <> '') and (DetailedCVLedgEntryBuffer."Document Type" = ...Payment) then AccNo := VendPostingGr."Payables Account"' with no call to the new IsApplnEntryForAppliedVendorDoc guard. Both procedures mirror each other line-for-line elsewhere in this codeunit (apply vs. unapply of the same detailed CV ledger entry buffer rows). Since the new test only exercises apply and not unapply, unapplying a payment that was applied via "Applies-to Doc. No." across two different vendor posting groups will still post the reversal to the payment's own Payables Account instead of the invoice's own posting group account, recreating the same G/L imbalance this PR fixes for the apply path. Impact would be major/blocker (unbalanced Payables Accounts after unapply) if confirmed; recommend applying the same IsApplnEntryForAppliedVendorDoc check inside PostDtldVendLedgEntryUnapply and adding a matching unapply test case, and until then this should be treated as a real defect rather than a minor one. Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
…dG/LEntriesIfyouApply-PaymentPostedPurchase
…dG/LEntriesIfyouApply-PaymentPostedPurchase
3c41da9
Agentic PR Review - Round 2Recommendation: AcceptWhat this PR doesThe new commit adds the same The added code is narrow and matches the apply-side account selection shape: the payment-side application entry can still use the payment posting group's payables account, while an applied document entry can fall back to Status of previous suggestions
New observations (commits since round 1)None - the only author-owned change since round 1 is the unapply guard, and I did not find a new issue in that change. Risk assessment and necessityRisk: This remains sensitive ES vendor posting code because it controls payables account G/L entries during apply and unapply with multiple vendor posting groups. The round-2 code change is only three added lines in the ES Necessity: The original bug is valid and important: users can get unbalanced payables accounts when applying a payment to a posted purchase invoice through the inline
|
…dG/LEntriesIfyouApply-PaymentPostedPurchase
|
Heads up, these build failures aren't from your code changes. The special character (a stray |
|
Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed. Use that pattern for every issue you want to link. |
I have create new PR