---
title: "Codeunit 816 Purch. Post Invoice"
author: "Jonas Paprotka"
url: https://jonas-paprotka.de/ref/codeunit/816-purch-post-invoice/
type: codeunit
id: 816
name: "Purch. Post Invoice"
app: "Base Application"
namespace: Microsoft.Purchases.Posting
versions: "19-28"
build: 28.5.54151.54365
source: "https://jonas-paprotka.de/ref/codeunit/816-purch-post-invoice/source/29/"
checked: 2026-09-20
subject: "Microsoft Dynamics 365 Business Central"
license: "Content © 2026 Jonas Paprotka. Quote freely with attribution and a link."
---

# Codeunit 816 Purch. Post Invoice

Jonas Paprotka, https://jonas-paprotka.de/ref/codeunit/816-purch-post-invoice/

| | |
| --- | --- |
| App | Base Application |
| Namespace | Microsoft.Purchases.Posting |
| Versions | 19-28 |
| Source file | Purchases/Posting/PurchPostInvoice.Codeunit.al |

## Procedures

| Name | Parameters | Returns | Access | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- | --- |
| Check | (Integer) | - | public | 19-28 | - | - |
| SetPreviewMode | (Boolean) | - | public | 19-28 | - | - |
| SetSuppressCommit | (Boolean) | - | public | 19-28 | - | - |
| SetHideProgressWindow | (Boolean) | - | public | 19-28 | - | - |
| SetParameters | (Record Invoice Posting Parameters) | - | public | 19-28 | - | - |
| SetTotalLines | (Variant, Variant) | - | public | 19-28 | - | - |
| ClearBuffers | () | - | public | 19-28 | - | - |
| PrepareLine | (Variant, Variant, Variant) | - | public | 19-28 | - | - |
| PostLines | (Variant, var Codeunit Gen. Jnl.-Post Line, var Dialog, var Decimal) | - | public | 19-28 | - | - |
| PrepareJobLine | (Variant, Variant, Variant) | - | public | 19-28 | - | - |
| CheckCreditLine | (Variant, Variant) | - | public | 19-28 | - | - |
| PostLedgerEntry | (Variant, var Codeunit Gen. Jnl.-Post Line) | - | public | 19-28 | - | - |
| PostBalancingEntry | (Variant, var Codeunit Gen. Jnl.-Post Line) | - | public | 19-28 | - | - |
| CalcDeferralAmounts | (Variant, Variant, Decimal) | - | public | 19-28 | - | - |
| CreatePostedDeferralSchedule | (Variant, Integer, Code[20], Integer, Date) | - | public | 19-28 | - | - |
| PrepareInvoicePostingBuffer | (var Record Purchase Line, var Record Invoice Posting Buffer) | - | public | 25-28 | - | - |
| SetSalesTax | (var Record Purchase Line, var Record Invoice Posting Buffer) | - | public | 25-28 | - | - |
| CreateTempFA | (Record Gen. Journal Line, Integer, var Record Fixed Asset) | Boolean | public | 27-28 | - | - |

## Events

| Kind | Name | Parameters | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- |
| Integration event | OnAfterCalcInvoiceDiscountPosting | (Record Purchase Header, Record Purchase Line, Record Purchase Line, Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnAfterCalcLineDiscountPosting | (Record Purchase Header, Record Purchase Line, Record Purchase Line, Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnAfterCreatePostedDeferralSchedule | (Record Purchase Line, var Record Posted Deferral Header) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnAfterGetPurchAccount | (Record Purchase Line, Record General Posting Setup, var Code[20]) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnAfterInitTotalAmounts | (Record Purchase Line, Record Purchase Line, var Decimal, var Decimal, var Decimal, var Decimal, var Decimal, var Decimal) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnAfterPrepareGenJnlLine | (var Record Gen. Journal Line, Record Purchase Header, Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnAfterSetJobLineFilters | (var Record Purchase Line, Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnAfterSetApplyToDocNo | (var Record Gen. Journal Line, Record Purchase Header) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforeCalcInvoiceDiscountPosting | (Record Purchase Header, Record Purchase Line, Record Purchase Line, var Record Invoice Posting Buffer, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforeCalcLineDiscountPosting | (Record Purchase Header, Record Purchase Line, Record Purchase Line, var Record Invoice Posting Buffer, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforeCalculateVATAmounts | (Record Purchase Header, var Record Invoice Posting Buffer, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforeInitGenJnlLine | (var Record Gen. Journal Line, Record Purchase Header, Record Invoice Posting Buffer, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforeInitGenJnlLineAmountFieldsFromTotalPurchLine | (var Record Gen. Journal Line, var Record Purchase Header, var Record Purchase Line, var Record Purchase Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforePostLines | (Record Purchase Header, var Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPostBalancingEntryOnAfterGenJnlPostLine | (var Record Gen. Journal Line, var Record Purchase Header, var Record Purchase Line, var Record Purchase Line, Boolean, Boolean, var Codeunit Gen. Jnl.-Post Line) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPostLedgerEntryOnAfterGenJnlPostLine | (var Record Gen. Journal Line, var Record Purchase Header, var Record Purchase Line, var Record Purchase Line, Boolean, Boolean, var Codeunit Gen. Jnl.-Post Line) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPostBalancingEntryOnBeforeGenJnlPostLine | (var Record Gen. Journal Line, var Record Purchase Header, var Record Purchase Line, var Record Purchase Line, Boolean, Boolean, var Codeunit Gen. Jnl.-Post Line) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPostLedgerEntryOnBeforeGenJnlPostLine | (var Record Gen. Journal Line, var Record Purchase Header, var Record Purchase Line, var Record Purchase Line, Boolean, Boolean, var Codeunit Gen. Jnl.-Post Line) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforePrepareLine | (Record Purchase Header, Record Purchase Line, Record Purchase Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforePrepareLineFADiscount | (var Record Invoice Posting Buffer, Record General Posting Setup, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforePostLedgerEntry | (var Record Purchase Header, Record Purchase Line, Record Purchase Line, Record Invoice Posting Parameters, var Codeunit Gen. Jnl.-Post Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnBeforeTempDeferralLineInsert | (var Record Deferral Line, Record Deferral Line, Record Purchase Line, var Integer, var Integer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnCalculateVATAmountsOnAfterGetReverseChargeVATPostingSetup | (var Record VAT Posting Setup) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterAssignAmounts | (Record Purchase Line, Record Purchase Line, var Decimal, var Decimal) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterSetAmounts | (var Record Invoice Posting Buffer, Record Purchase Line) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterFillInvoicePostingBuffer | (var Record Invoice Posting Buffer, Record Purchase Line) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforeAdjustTotalAmounts | (Record Purchase Line, var Decimal, var Decimal, Date) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforeSetAccount | (Record Purchase Header, Record Purchase Line, var Code[20]) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforeSetAmounts | (Record Purchase Line, Record Purchase Line, var Record Invoice Posting Buffer, var Decimal, var Decimal, var Decimal, var Decimal, var Decimal, var Decimal, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterSetInvoiceDiscAccount | (Record Purchase Line, Record General Posting Setup, var Record Invoice Posting Buffer, var Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterSetLineDiscAccount | (Record Purchase Line, Record General Posting Setup, var Record Invoice Posting Buffer, var Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforeCalcInvoiceDiscountPosting | (var Record Invoice Posting Buffer, var Record Invoice Posting Buffer, Record Purchase Header, Record Purchase Line, Decimal, Decimal, Decimal, Decimal, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforeCalcLineDiscountPosting | (var Record Invoice Posting Buffer, var Record Invoice Posting Buffer, Record Purchase Header, Record Purchase Line, Decimal, Decimal, Decimal, Decimal, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPostLinesOnAfterGenJnlLinePost | (var Record Gen. Journal Line, Record Purchase Header, Record Invoice Posting Buffer, var Codeunit Gen. Jnl.-Post Line, Boolean, Boolean, Integer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPostLinesOnBeforeGenJnlLinePost | (var Record Gen. Journal Line, Record Purchase Header, Record Invoice Posting Buffer, var Codeunit Gen. Jnl.-Post Line, Boolean, Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareGenJnlLineOnAfterCopyToGenJnlLine | (var Record Gen. Journal Line, Record Purchase Header, Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterSetInvoiceDiscountPosting | (Record Purchase Header, Record Purchase Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterSetLineDiscountPosting | (Record Purchase Header, Record Purchase Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterPrepareDeferralLine | (Record Purchase Line, Record Invoice Posting Buffer, Date, Integer, Integer, Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnAfterUpdateInvoicePostingBuffer | (Record Purchase Header, Record Purchase Line, Record Invoice Posting Buffer, var Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforePrepareDeferralLine | (Record Purchase Line, Record Invoice Posting Buffer, Date, Integer, Integer, Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforePreparePurchase | (Record Purchase Header, Record Purchase Line) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforeSetInvoiceDiscAccount | (Record Purchase Line, Record General Posting Setup, var Code[20], var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareLineOnBeforeSetLineDiscAccount | (Record Purchase Line, Record General Posting Setup, var Code[20], var Boolean) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnPrepareDeferralLineOnBeforeDeferralPostingBufferPrepareInitialAmounts | (var Record Deferral Posting Buffer, Record Purchase Header, Record Purchase Line, Decimal, Decimal, Decimal, Decimal, Code[20], Code[20]) | 19-22 | Pending 20.0 | Replaced by run event procedure in codeunit Purch. Post Invoice Events |
| Integration event | OnSplitFAOnBeforeRunGenJnlPostLine | (var Record Gen. Journal Line, var Record Gen. Journal Line, var Record Gen. Journal Line, Integer, Integer) | 28 | - | - |

## Source

Symbols: Microsoft.BaseApplication.symbols.437dbf0e-84ff-417a-965d-ed2bb9650972, https://dynamicssmb2.pkgs.visualstudio.com/DynamicsBCPublicFeeds/_packaging/MSSymbols/nuget/v3/index.json, highest build per major on 2026-09-20.
AL source 29: https://github.com/microsoft/BCApps, MIT, releases/29.x at a66254c3b8b5bb1cea290dc8f9d097aec4381153.

Jonas Paprotka, 2026-09-20.
