---
title: "Codeunit 815 Sales Post Invoice"
author: "Jonas Paprotka"
url: https://jonas-paprotka.de/ref/codeunit/815-sales-post-invoice/
type: codeunit
id: 815
name: "Sales Post Invoice"
app: "Base Application"
namespace: Microsoft.Sales.Posting
versions: "19-28"
build: 28.5.54151.54365
source: "https://jonas-paprotka.de/ref/codeunit/815-sales-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 815 Sales Post Invoice

Jonas Paprotka, https://jonas-paprotka.de/ref/codeunit/815-sales-post-invoice/

| | |
| --- | --- |
| App | Base Application |
| Namespace | Microsoft.Sales.Posting |
| Versions | 19-28 |
| Source file | Sales/Posting/SalesPostInvoice.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 | - | - |
| SetSalesTax | (var Record Sales Line, var Record Invoice Posting Buffer) | - | internal | 25-28 | - | - |
| PrepareInvoicePostingBuffer | (var Record Sales Line, var Record Invoice Posting Buffer) | - | public | 25-28 | - | - |

## Events

| Kind | Name | Parameters | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- |
| Integration event | OnAfterCalcInvoiceDiscountPosting | (Record Sales Header, Record Sales Line, Record Sales Line, Record Invoice Posting Buffer) | 19 | - | - |
| Integration event | OnAfterCalcLineDiscountPosting | (Record Sales Header, Record Sales Line, Record Sales Line, Record Invoice Posting Buffer) | 19 | - | - |
| Integration event | OnAfterCreatePostedDeferralScheduleFromSalesDoc | (var Record Sales Line, var Record Posted Deferral Header) | 19-22 | Pending 20.0 | Replaced by RunOnAfterCreatePostedDeferralScheduleFromSalesDoc in codeunit Sales Post Invoice Subscr. |
| Integration event | OnAfterGetSalesAccount | (Record Sales Line, Record General Posting Setup, var Code[20]) | 19-22 | Pending 20.0 | Replaced by RunOnAfterGetSalesAccount in codeunit Sales Post Invoice Subscr. |
| Integration event | OnAfterPrepareGenJnlLine | (var Record Gen. Journal Line, Record Sales Header, Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by RunOnAfterPrepareGenJnlLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnAfterSetApplyToDocNo | (var Record Gen. Journal Line, Record Sales Header) | 19-22 | Pending 20.0 | Replaced by RunOnAfterSetApplyToDocNo in codeunit Sales Post Invoice Subscr. |
| Integration event | OnAfterSetJobLineFilters | (var Record Sales Line, Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by RunOnAfterSetJobLineFilters in codeunit Sales Post Invoice Subscr. |
| Integration event | OnBeforeCalcInvoiceDiscountPosting | (Record Sales Header, Record Sales Line, Record Sales Line, var Record Invoice Posting Buffer, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnBeforeCalcInvoiceDiscountPosting in codeunit Sales Post Invoice Subscr. |
| Integration event | OnBeforeCalcLineDiscountPosting | (Record Sales Header, Record Sales Line, Record Sales Line, var Record Invoice Posting Buffer, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnBeforeCalcLineDiscountPosting in codeunit Sales Post Invoice Subscr. |
| Integration event | OnBeforeInitGenJnlLine | (var Record Gen. Journal Line, Record Sales Header, Record Invoice Posting Buffer, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnBeforeInitGenJnlLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnBeforePostLines | (Record Sales Header, var Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by RunOnBeforePostLines in codeunit Sales Post Invoice Subscr. |
| Integration event | OnBeforePostLedgerEntry | (var Record Sales Header, var Record Sales Line, var Record Sales Line, Boolean, Boolean, Record Invoice Posting Parameters, var Codeunit Gen. Jnl.-Post Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnBeforePostLedgerEntry in codeunit Sales Post Invoice Subscr. |
| Integration event | OnBeforePrepareLine | (Record Sales Header, Record Sales Line, Record Sales Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnBeforePrepareLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnBeforeSetAmountsForBalancingEntry | (var Record Cust. Ledger Entry, var Record Gen. Journal Line, var Record Sales Line, var Record Sales Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnBeforeSetAmountsForBalancingEntry in codeunit Sales Post Invoice Subscr. |
| Integration event | OnBeforeTempDeferralLineInsert | (var Record Deferral Line, Record Deferral Line, Record Sales Line, var Integer, var Integer) | 19-22 | Pending 20.0 | Replaced by RunOnBeforeTempDeferralLineInsert in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPostBalancingEntryOnBeforeFindCustLedgEntry | (Record Sales Header, Record Sales Line, Record Invoice Posting Parameters, var Record Cust. Ledger Entry, var Boolean, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPostBalancingEntryOnBeforeFindCustLedgEntry in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPostLedgerEntryOnAfterGenJnlPostLine | (var Record Gen. Journal Line, var Record Sales Header, var Record Sales Line, var Record Sales Line, Boolean, var Codeunit Gen. Jnl.-Post Line) | 19-22 | Pending 20.0 | Replaced by RunOnPostLedgerEntryOnAfterGenJnlPostLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPostLedgerEntryOnBeforeGenJnlPostLine | (var Record Gen. Journal Line, var Record Sales Header, var Record Sales Line, var Record Sales Line, Boolean, Boolean, var Codeunit Gen. Jnl.-Post Line) | 19-22 | Pending 20.0 | Replaced by RunOnPostLedgerEntryOnBeforeGenJnlPostLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPostBalancingEntryOnAfterGenJnlPostLine | (var Record Gen. Journal Line, var Record Sales Header, var Record Sales Line, var Record Sales Line, Boolean, var Codeunit Gen. Jnl.-Post Line) | 19-22 | Pending 20.0 | Replaced by RunOnPostBalancingEntryOnAfterGenJnlPostLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPostBalancingEntryOnBeforeGenJnlPostLine | (var Record Gen. Journal Line, var Record Sales Header, var Record Sales Line, var Record Sales Line, Boolean, Boolean, var Codeunit Gen. Jnl.-Post Line) | 19-22 | Pending 20.0 | Replaced by RunOnPostBalancingEntryOnBeforeGenJnlPostLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPostBalancingEntryOnAfterFindCustLedgEntry | (var Record Cust. Ledger Entry) | 19-22 | Pending 20.0 | Replaced by RunOnPostBalancingEntryOnAfterFindCustLedgEntry in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterAssignAmounts | (Record Sales Line, Record Sales Line, var Decimal, var Decimal) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterAssignAmounts in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterSetAmounts | (var Record Invoice Posting Buffer, Record Sales Line) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterSetAmounts in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterFillInvoicePostingBuffer | (var Record Invoice Posting Buffer, Record Sales Line) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterFillInvoicePostingBuffer in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforeAdjustTotalAmounts | (Record Sales Line, var Decimal, var Decimal, Date) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnBeforeAdjustTotalAmounts in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforeSetAccount | (Record Sales Header, Record Sales Line, var Code[20]) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnBeforeSetAccount in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforeSetAmounts | (Record Sales Line, Record Sales 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 RunOnPrepareLineOnBeforeSetAmounts in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterSetInvoiceDiscAccount | (Record Sales Line, Record General Posting Setup, var Record Invoice Posting Buffer, var Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterSetInvoiceDiscAccount in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterSetLineDiscAccount | (Record Sales Line, Record General Posting Setup, var Record Invoice Posting Buffer, var Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterSetLineDiscAccount in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforeCalcInvoiceDiscountPosting | (var Record Invoice Posting Buffer, var Record Invoice Posting Buffer, Record Sales Header, Record Sales Line, Decimal, Decimal, Decimal, Decimal, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnBeforeCalcInvoiceDiscountPosting in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforeCalcLineDiscountPosting | (var Record Invoice Posting Buffer, var Record Invoice Posting Buffer, Record Sales Header, Record Sales Line, Decimal, Decimal, Decimal, Decimal, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnBeforeCalcLineDiscountPosting in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPostLinesOnAfterGenJnlLinePost | (var Record Gen. Journal Line, Record Sales Header, Record Invoice Posting Buffer, var Codeunit Gen. Jnl.-Post Line, Boolean, Boolean, Integer) | 19-22 | Pending 20.0 | Replaced by RunOnPostLinesOnAfterGenJnlLinePost in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPostLinesOnBeforeGenJnlLinePost | (var Record Gen. Journal Line, Record Sales Header, Record Invoice Posting Buffer, var Codeunit Gen. Jnl.-Post Line, Boolean, Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPostLinesOnBeforeGenJnlLinePost in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareGenJnlLineOnAfterCopyToGenJnlLine | (var Record Gen. Journal Line, Record Sales Header, Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareGenJnlLineOnAfterCopyToGenJnlLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterSetInvoiceDiscountPosting | (Record Sales Header, Record Sales Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterSetInvoiceDiscountPosting in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterSetLineDiscountPosting | (Record Sales Header, Record Sales Line, var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterSetLineDiscountPosting in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterPrepareDeferralLine | (Record Sales Line, Record Invoice Posting Buffer, Date, Integer, Integer, Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterPrepareDeferralLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnAfterUpdateInvoicePostingBuffer | (Record Sales Header, Record Sales Line, Record Invoice Posting Buffer, var Record Invoice Posting Buffer) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnAfterUpdateInvoicePostingBuffer in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforePrepareDeferralLine | (Record Sales Line, Record Invoice Posting Buffer, Date, Integer, Integer, Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnBeforePrepareDeferralLine in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforePrepareSales | (Record Sales Header, Record Sales Line) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnBeforePrepareSales in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforeSetInvoiceDiscAccount | (Record Sales Line, Record General Posting Setup, var Code[20], var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnBeforeSetInvoiceDiscAccount in codeunit Sales Post Invoice Subscr. |
| Integration event | OnPrepareLineOnBeforeSetLineDiscAccount | (Record Sales Line, Record General Posting Setup, var Code[20], var Boolean) | 19-22 | Pending 20.0 | Replaced by RunOnPrepareLineOnBeforeSetLineDiscAccount in codeunit Sales Post Invoice Subscr. |
| Integration event | OnAfterCalcInvoiceDiscountPosting | (Record Sales Header, Record Sales Line, Record Sales Line, var Record Invoice Posting Buffer) | 20-22 | Pending 20.0 | Replaced by RunOnAfterCalcInvoiceDiscountPosting in codeunit Sales Post Invoice Events. |
| Integration event | OnAfterCalcLineDiscountPosting | (Record Sales Header, Record Sales Line, Record Sales Line, var Record Invoice Posting Buffer) | 20-22 | Pending 20.0 | Replaced by RunOnAfterCalcLineDiscountPosting in codeunit Sales Post Invoice Subscr. |

## 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.
