bcquality/microsoft/knowledge/finance/apply-ledger-entries-through-application-codeunits.md
Jesper Schulz-Wedde 7c17aa3ab8 Fix Finance review applicability and ownership boundaries
Remove application-area gating and later VAT-field dependencies, align dynamic shared conventions, separate SCM ownership, and keep journal examples focused on the intended invariant.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-17 18:10:21 +02:00

3.3 KiB

bc-version domain keywords technologies countries application-area
all
finance
cust-ledger-entry
vendor-ledger-entry
detailed-ledger-entry
remaining-amount
application
unapplication
open
closed-by-entry-no
al
w1
all

Apply and unapply entries through the application workflow, not status flags

Description

Customer/vendor settlement is a posting operation involving detailed ledger entries, not just a change to Open on the main entry. Remaining amounts are calculated from detailed entries. Unapplication posts correcting entries and handles application-derived effects such as discounts and currency gains/losses; deleting details or changing Unapplied cannot reproduce that history.

Best Practice

Use "CustEntry-Apply Posted Entries" / "VendEntry-Apply Posted Entries" and the supported application or unapplication workflow. Let it check application dates, entry state, and application ordering. The ApplyCustEntryFormEntry / ApplyVendEntryFormEntry and UnApply...LedgEntry methods are interactive: users select and confirm the operation. They are not unattended "mark paid" APIs.

For programmatic posting, use the target version's public Apply / PostUnApply... APIs with properly prepared selection and Apply Unapply Parameters; handle cancellation and the workflow's transaction/commit behavior. "Applying Entry", "Applies-to ID", and "Amount to Apply" are legitimate application-preparation fields. Do not report their writes alone, temporary buffers, supported posting/compression internals, or unrelated operational/extension fields.

See sample: apply-ledger-entries-through-application-codeunits.good.al.

Anti Pattern

Implement customer/vendor payment matching, settlement, or reopening by directly persisting Open, "Closed by Entry No.", closure amounts/dates, or detailed-entry unapplication flags, or by deleting/rewriting detailed application amounts. Require confirmed writes to existing non-temporary customer/vendor or detailed customer/vendor entries and settlement intent. Item/inventory application records belong to SCM, not this rule. Do not suggest assigning a Remaining Amount FlowField as a fix.

This article owns fabricated application state. Use the posted-financial-content rule for original accounting-value corrections, not a second finding prescribing the same application fix.

See sample: apply-ledger-entries-through-application-codeunits.bad.al.

References