Skip to content

[Main]-Payment discount tolerance is doubled when posting a vendor payment - #9789

Open
DhavalMore88 wants to merge 3 commits into
microsoft:mainfrom
DhavalMore88:bugs/Bug-644282-Main-Payment-discount-tolerance-is-doubled
Open

[Main]-Payment discount tolerance is doubled when posting a vendor payment#9789
DhavalMore88 wants to merge 3 commits into
microsoft:mainfrom
DhavalMore88:bugs/Bug-644282-Main-Payment-discount-tolerance-is-doubled

Conversation

@DhavalMore88

@DhavalMore88 DhavalMore88 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the From Fork Pull request is coming from a fork label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
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.

@github-actions github-actions Bot added Finance GitHub request for Finance area Linked Issue is linked to a Azure Boards work item labels Jul 28, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 28, 2026
@DhavalMore88
DhavalMore88 marked this pull request as ready for review July 28, 2026 13:14
@DhavalMore88
DhavalMore88 requested a review from a team July 28, 2026 13:14
@DhavalMore88 DhavalMore88 self-assigned this Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Issue #644282 is not valid. Please make sure you link an issue that exists, is open and is approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Finance GitHub request for Finance area From Fork Pull request is coming from a fork Linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant