---
id: object/codeunit/815
type: object
title: Codeunit 815 "Sales Post Invoice"
summary: Codeunit 815 "Sales Post Invoice" in Base Application (Microsoft.Sales.Posting). 17 public procedures. Present since at least BC23, still in BC30, changed in BC24-26.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "26"
  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: 379b4f5d2ec7cec87d5971c01c310d052b4e63b28a7492fd8365fff246b057bd
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Sales/Posting/SalesPostInvoice.Codeunit.al
    title: src/Layers/W1/BaseApp/Sales/Posting/SalesPostInvoice.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations:
    - localization/au
    - localization/ca
    - localization/it
    - localization/mx
    - localization/nz
    - localization/us
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/11434
    - change/bcapps/10513
    - change/bcapps/11160
    - change/bcapps/10877
object_type: codeunit
object_id: 815
name: Sales Post Invoice
namespace: Microsoft.Sales.Posting
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "25"
  - "26"
source_major: "29"
obsolete: null
countries:
  - au
  - ca
  - it
  - mx
  - nz
  - us
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 34
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 7
  called_by: 0
  implements: 1
---

# Codeunit 815 "Sales Post Invoice"

> Codeunit 815 "Sales Post Invoice" in Base Application (Microsoft.Sales.Posting). 17 public procedures. Present since at least BC23, still in BC30, changed in BC24-26.

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

## Properties

| Property | Value |
|---|---|
| Permissions | TableData "Invoice Posting Buffer" = rimd |

## Procedures

- `Check(TableID: Integer)`: Validates that the correct table is being used for invoice posting.
- `SetPreviewMode(NewPreviewMode: Boolean)`: Sets whether the invoice posting is running in preview mode.
- `SetSuppressCommit(NewSuppressCommit: Boolean)`: Sets whether database commits should be suppressed during invoice posting.
- `SetHideProgressWindow(NewHideProgressWindow: Boolean)`: Sets whether the progress window should be hidden during invoice posting.
- `SetParameters(NewInvoicePostingParameters: Record "Invoice Posting Parameters")`: Sets the invoice posting parameters to be used during posting.
- `SetTotalLines(TotalDocumentLine: Variant; TotalDocumentLineLCY: Variant)`: Sets the total lines used for posting the customer ledger entry.
- `ClearBuffers()`: Clears all temporary buffers used for deferral and invoice posting.
- `PrepareLine(DocumentHeaderVar: Variant; DocumentLineVar: Variant; DocumentLineACYVar: Variant)`: Prepares a sales line for invoice posting by calculating amounts and creating invoice posting buffer entries.
- `SetSalesTax(var SalesLine: Record "Sales Line"; var InvoicePostingBuffer: Record "Invoice Posting Buffer")` (internal)
- `PrepareInvoicePostingBuffer(var SalesLine: Record "Sales Line"; var InvoicePostingBuffer: Record "Invoice Posting Buffer")`: Initializes the invoice posting buffer with values from the sales line.
- `PostLines(DocumentHeaderVar: Variant; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var Window: Dialog; var TotalAmount: Decimal)`: Posts all invoice posting buffer lines to the general ledger.
- `PrepareJobLine(SalesHeaderVar: Variant; SalesLineVar: Variant; SalesLineACYVar: Variant)`: Prepares and posts job-related entries for the sales line.
- `CheckCreditLine(SalesHeaderVar: Variant; SalesLineVar: Variant)`: Validates the sales line for credit memo posting. Currently not implemented.
- `PostLedgerEntry(SalesHeaderVar: Variant; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line")`: Posts the customer ledger entry for the sales invoice or credit memo.
- `PostBalancingEntry(SalesHeaderVariant: Variant; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line")`: Posts the balancing entry to apply payment to the customer ledger entry when a balancing account is specified.
- `CalcDeferralAmounts(SalesHeaderVar: Variant; SalesLineVar: Variant; OriginalDeferralAmount: Decimal)`: Calculates the deferral amounts for the sales line based on the quantity being invoiced.
- `CreatePostedDeferralSchedule(SalesLineVar: Variant; NewDocumentType: Integer; NewDocumentNo: Code[20]; NewLineNo: Integer; PostingDate: Date)`: Creates the posted deferral schedule from the sales line deferral information.

Plus 17 local procedures.

## 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 825 "Sales Post Invoice Events"](../codeunit/825.md) (59 calls: `CalcDeferralAmounts → RunOnBeforeTempDeferralLineInsert`, `CalcDeferralAmounts → RunOnCalcDeferralAmountsOnBeforeTempDeferralHeaderInsert`, `CalcInvoiceDiscountPosting → RunOnAfterCalcInvoiceDiscountPosting`, …)
- [Codeunit 1720 "Deferral Utilities"](../codeunit/1720.md) (4 calls: `CalcDeferralAmounts → FilterDeferralLines`, `CreatePostedDeferralSchedule → FilterDeferralLines`, `PrepareDeferralLine → FilterDeferralLines`, …)
- [Codeunit 12 "Gen. Jnl.-Post Line"](../codeunit/12.md) (3 calls: `PostBalancingEntry → RunWithCheck`, `PostLedgerEntry → RunWithCheck`, `RunGenJnlPostLine → RunWithCheck`)
- [Codeunit 1001 "Job Post-Line"](../codeunit/1001.md) (2 calls: `PostLines → PostJobSalesLines`, `PrepareJobLine → PostInvoiceContractLine`)
- [Codeunit 442 "Sales-Post Prepayments"](../codeunit/442.md) (2 calls: `PrepareLine → GetCorrBalAccNo`, `PrepareLine → GetInvRoundingAccNo`)
- [Codeunit 408 "DimensionManagement"](../codeunit/408.md) (1 call: `PrepareInvoicePostingBuffer → UpdateGlobalDimFromDimSetID`)
- [Codeunit 6200 "Non-Deductible VAT"](../codeunit/6200.md) (1 call: `PrepareInvoicePostingBuffer → ClearNonDeductibleVAT`)

## Implements

- [Interface "Invoice Posting"](../interface/invoice-posting.md)

## Recent changes

- 2026-09-21 [#11434 [main] Incorrect Additional Currency Base and Additional Currency Amount calculation in VAT/GST Entries when Line Discount is applied on Sales Invoice in the Australian version.](../../changes/bcapps/11434.md) (main, BC30, fix)
- 2026-09-18 [#10513 [Extensibility Request] issue 30270: expose JobPostLine before calculating totals](../../changes/bcapps/10513.md) (main, BC30, feature)
- 2026-09-09 [#11160 Ruleset hardening: promote three mechanical rules to Error](../../changes/bcapps/11160.md) (main, BC30, refactor)
- 2026-09-07 [#10877 [MAIN]-Bug 648518 Source Currency VAT Amount is zero on G/L Entry when posting sales invoice with Line Discount Deferral Code and Discount Posting is No Discounts](../../changes/bcapps/10877.md) (main, BC30, fix)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24-26

## Countries that replace it

[AU](../../localizations/au.md), [CA](../../localizations/ca.md), [IT](../../localizations/it.md), [MX](../../localizations/mx.md), [NZ](../../localizations/nz.md), [US](../../localizations/us.md)

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: "Sales Post Invoice")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
