[Main]-Payment discount tolerance is doubled when posting a vendor payment - #9789
Open
DhavalMore88 wants to merge 3 commits into
Open
Conversation
Contributor
|
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. |
…unt-tolerance-is-doubled
Contributor
|
Issue #644282 is not valid. Please make sure you link an issue that exists, is open and is approved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug 644282: [master] [ALL-E]Payment discount tolerance is doubled when posting a vendor payment
AB#644282
Issue: When posting a vendor payment that applies to multiple invoices via Applies-to ID in a foreign currency within the payment discount grace period (accepting payment discount tolerance), the payment discount tolerance amount is doubled in the resulting G/L entries. Instead of Bank = 7092.34 / Payment Discount = 144.74, the bank leg is inflated to 7381.82 and the discount sign is flipped, producing a net error of 289.48 (exactly 2× the 144.74 tolerance).
Cause: In ManagePaymentDiscToleranceWarningVendor in PaymentToleranceManagement.Codeunit.al, the else-branch correctly nets the payment amount down (7237.08 → 7092.34) across the applied invoices, but persisted it via UpdateGenJournalLineAmount only when GenJnlLineApplID = ''. Since the Applies-to ID scenario always has a non-empty ID, this guard was never satisfied (and was mutually exclusive with UpdateGenJournalLineAmount's own internal "Applies-to ID" <> '' guard), so the netted amount was discarded and the journal line stayed gross. At posting, CalcPmtDiscTolerance (codeunit 12) then posts an extra 144.74 with no liability guard, doubling the tolerance.
Solution: Removed the dead if GenJnlLineApplID = '' guard so the netted amount is always persisted to the journal line via UpdateGenJournalLineAmount (whose internal "Applies-to ID" <> '' check correctly permits it for the Applies-to ID case). Added an UpdatingGenJnlLineAmount re-entrancy guard with an early exit(true) in PmtTolGenJnl, set around the Validate("Amount")/Modify call, to prevent infinite recursion since validating Amount re-triggers PmtTolGenJnl. The customer path was left unchanged as the defect is vendor-scoped.