---
id: object/codeunit/441
type: object
title: Codeunit 441 "Prepayment Mgt."
summary: Codeunit 441 "Prepayment Mgt." in Base Application (Microsoft.Finance.ReceivablesPayables). 14 public procedures, 11 events. Present since at least BC23, still in BC30, changed in BC28.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "28"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 0195fa79a99dc6a3385a2d7ee6b7a6f45d56dc5c5ea39d7a221634cd8b2320cc
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Finance/ReceivablesPayables/PrepaymentMgt.Codeunit.al
    title: src/Layers/W1/BaseApp/Finance/ReceivablesPayables/PrepaymentMgt.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/9416
object_type: codeunit
object_id: 441
name: Prepayment Mgt.
namespace: Microsoft.Finance.ReceivablesPayables
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "28"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 28
  events: 11
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 4
  called_by: 17
  implements: 0
---

# Codeunit 441 "Prepayment Mgt."

> Codeunit 441 "Prepayment Mgt." in Base Application (Microsoft.Finance.ReceivablesPayables). 14 public procedures, 11 events. Present since at least BC23, still in BC30, changed in BC28.

Base Application · Microsoft.Finance.ReceivablesPayables · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Finance/ReceivablesPayables/PrepaymentMgt.Codeunit.al) · facts from BC29

## Events published

- `OnBeforeUpdatePendingPrepaymentSales(var SalesHeader: Record "Sales Header")` (integration): Integration event raised before pending prepayment sales orders are processed for release.
- `OnAfterUpdatePendingPrepaymentSales(var SalesHeader: Record "Sales Header")` (integration): Integration event raised after pending prepayment sales orders have been processed for release.
- `OnBeforeTestSalesPrepayment(SalesHeader: Record "Sales Header"; var TestResult: Boolean; var IsHandled: Boolean)` (integration): Integration event raised before testing sales prepayment requirements.
- `OnBeforeTestPurchPrepayment(PurchHeader: Record "Purchase Header"; var TestResult: Boolean; var IsHandled: Boolean)` (integration): Integration event raised before testing purchase prepayment requirements.
- `OnBeforeTestSalesPayment(var SalesHeader: Record "Sales Header"; var Result: Boolean; var IsHandled: Boolean)` (integration): Integration event raised before testing sales payment status.
- `OnBeforeTestPurchasePayment(PurchaseHeader: Record "Purchase Header"; var Result: Boolean; var IsHandled: Boolean)` (integration): Integration event raised before testing purchase payment status.
- `OnTestSalesPaymentOnBeforeCustLedgerEntrySetFilter(var CustLedgerEntry: Record "Cust. Ledger Entry"; SalesHeader: Record "Sales Header"; SalesInvHeader: Record "Sales Invoice Header")` (integration): Integration event raised before setting customer ledger entry filters in sales payment test.
- `OnTestPurchasePaymentOnBeforeVendLedgerEntrySetFilter(var VendLedgerEntry: Record "Vendor Ledger Entry"; PurchaseHeader: Record "Purchase Header"; PurchInvHeader: Record "Purch. Inv. Header")` (integration): Integration event raised before setting vendor ledger entry filters in purchase payment test.
- `OnBeforeSetSalesPrepaymentPct(var SalesLine: Record "Sales Line"; Date: Date; var IsHandled: Boolean)` (integration): Integration event raised before setting sales prepayment percentage.
- `OnBeforeTestSalesOrderLineForGetShptLines(SalesLine: Record "Sales Line"; var IsHandled: Boolean)` (integration): Integration event raised before testing sales order lines for get shipment lines operation.
- `OnBeforeTestPurchaseOrderLineForGetRcptLines(PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean)` (integration): Integration event raised before testing purchase order lines for get receipt lines operation.

## Procedures

- `AssertPrepmtAmountNotMoreThanDocAmount(DocumentTotalInclVAT: Decimal; PrepmtTotalInclVAT: Decimal; CurrencyCode: Code[10]; InvoiceRoundingSetup: Boolean)`: Validates that prepayment amount does not exceed the total document amount including VAT. Applies invoice rounding if configured and throws error if prepayment exceeds document total.
- `SetSalesPrepaymentPct(var SalesLine: Record "Sales Line"; Date: Date)`: Sets prepayment percentage on sales line based on customer and item prepayment configuration. Determines appropriate prepayment percentage from customer, item, or G/L account setup.
- `SetPurchPrepaymentPct(var PurchLine: Record "Purchase Line"; Date: Date)`: Sets purchase prepayment percentage based on purchase prepayment setup. Updates purchase line prepayment percentage from purchase prepayment percentage configuration.
- `TestSalesPrepayment(SalesHeader: Record "Sales Header"): Boolean`: Tests if sales document has prepayment requirements. Validates whether sales order contains prepayment percentages that require prepayment invoice processing.
- `TestPurchasePrepayment(PurchaseHeader: Record "Purchase Header"): Boolean`: Tests if purchase document has prepayment requirements. Validates whether purchase order contains prepayment percentages that require prepayment invoice processing.
- `TestSalesOrderLineForGetShptLines(SalesLine: Record "Sales Line")`: Tests sales order line for compatibility with Get Shipment Lines function. Validates that sales line can be processed when using Get Shipment Lines with prepayment scenarios.
- `TestPurchaseOrderLineForGetRcptLines(PurchaseLine: Record "Purchase Line")`: Tests purchase order line for compatibility with Get Receipt Lines function. Validates that purchase line can be processed when using Get Receipt Lines with prepayment scenarios.
- `TestSalesPayment(SalesHeader: Record "Sales Header"): Boolean`: Tests if sales prepayment invoices are paid before posting.
- `TestPurchasePayment(PurchaseHeader: Record "Purchase Header"): Boolean`: Tests if purchase prepayment invoices are paid before posting.
- `UpdatePendingPrepaymentSales()`: Updates pending prepayment status for sales orders.
- `UpdatePendingPrepaymentPurchase()`: Updates pending prepayment status for purchase orders.
- `CreateAndStartJobQueueEntrySales(UpdateFrequency: Option Never,Daily,Weekly)`: Creates and starts job queue entry for updating pending prepayment sales orders.
- `CreateAndStartJobQueueEntryPurchase(UpdateFrequency: Option Never,Daily,Weekly)`: Creates and starts job queue entry for updating pending prepayment purchase orders.
- `CreateAndStartJobQueueEntry(CodeunitID: Integer; UpdateFrequency: Option Never,Daily,Weekly; Category: Text)`: Creates and starts a job queue entry for automatic prepayment processing.

Plus 3 local procedures.

## Triggers

OnRun

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 456 "Job Queue Management"](../codeunit/456.md) (2 calls: `CreateAndStartJobQueueEntry → CreateJobQueueEntry`, `CreateAndStartJobQueueEntry → DeleteJobQueueEntries`)
- [Codeunit 414 "Release Sales Document"](../codeunit/414.md) (1 call: `UpdatePendingPrepaymentSales → (object)`)
- [Codeunit 415 "Release Purchase Document"](../codeunit/415.md) (1 call: `UpdatePendingPrepaymentPurchase → (object)`)
- [Codeunit 453 "Job Queue - Enqueue"](../codeunit/453.md) (1 call: `CreateAndStartJobQueueEntry → (object)`)

## Called by

- [Table 36 "Sales Header"](../table/36.md) (4 calls: `ApprovedForPostingBatch → TestSalesPayment`, `ApprovedForPostingBatch → TestSalesPrepayment`, `IsApprovedForPosting → TestSalesPayment`, …)
- [Codeunit 414 "Release Sales Document"](../codeunit/414.md) (3 calls: `CheckPrepaymentsForManualRelease → TestSalesPrepayment`, `Code → TestSalesPrepayment`, `PerformManualCheckAndRelease → TestSalesPayment`)
- [Codeunit 415 "Release Purchase Document"](../codeunit/415.md) (3 calls: `Code → TestPurchasePrepayment`, `PerformManualCheckAndRelease → TestPurchasePayment`, `PerformManualRelease → TestPurchasePrepayment`)
- [Table 38 "Purchase Header"](../table/38.md) (3 calls: `ApprovedForPostingBatch → TestPurchasePayment`, `IsApprovedForPosting → TestPurchasePayment`, `TestPurchasePrepayment → TestPurchasePrepayment`)
- [Codeunit 442 "Sales-Post Prepayments"](../codeunit/442.md) (2 calls: `SalesAssertPrepmtAmountNotMoreThanDocAmount → AssertPrepmtAmountNotMoreThanDocAmount`, `SalesAssertPrepmtAmountNotMoreThanDocAmountBeforePost → AssertPrepmtAmountNotMoreThanDocAmount`)
- [Codeunit 383 "Upd. Pending Prepmt. Sales"](../codeunit/383.md) (1 call: `OnRun → UpdatePendingPrepaymentSales`)
- [Codeunit 384 "Upd. Pending Prepmt. Purchase"](../codeunit/384.md) (1 call: `OnRun → UpdatePendingPrepaymentPurchase`)
- [Codeunit 444 "Purchase-Post Prepayments"](../codeunit/444.md) (1 call: `PurchaseAssertPrepmtAmountNotMoreThanDocAmount → AssertPrepmtAmountNotMoreThanDocAmount`)
- [Codeunit 5341 "CRM Int. Table. Subscriber"](../codeunit/5341.md) (1 call: `SetSalesOrderStatus → TestSalesPrepayment`)
- [Codeunit 86 "Sales-Quote to Order"](../codeunit/86.md) (1 call: `TransferQuoteToOrderLines → SetSalesPrepaymentPct`)
- [Codeunit 87 "Blanket Sales Order to Order"](../codeunit/87.md) (1 call: `CreateSalesOrderLines → SetSalesPrepaymentPct`)
- [Codeunit 96 "Purch.-Quote to Order"](../codeunit/96.md) (1 call: `TransferQuoteToOrderLines → SetPurchPrepaymentPct`)
- [Codeunit 97 "Blanket Purch. Order to Order"](../codeunit/97.md) (1 call: `OnRun → SetPurchPrepaymentPct`)
- [Table 111 "Sales Shipment Line"](../table/111.md) (1 call: `InsertInvLineFromShptLine → TestSalesOrderLineForGetShptLines`)
- [Table 121 "Purch. Rcpt. Line"](../table/121.md) (1 call: `InsertInvLineFromRcptLine → TestPurchaseOrderLineForGetRcptLines`)
- [Table 37 "Sales Line"](../table/37.md) (1 call: `CopyFromItem → SetSalesPrepaymentPct`)
- [Table 39 "Purchase Line"](../table/39.md) (1 call: `CopyFromItem → SetPurchPrepaymentPct`)

## Recent changes

- 2026-07-16 [#9416 [ALAppExtensions #30313]codeunit 441 "Prepayment Mgt." OnBeforeReleaseSalesDocument](../../changes/bcapps/9416.md) (main, BC30, feature)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC28

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Prepayment Mgt.")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
