Codeunit 1303 "Correct Posted Sales Invoice"
Base Application · Microsoft.Sales.History
Across versions
- BC23present
- BC243 events added, 1 procedures added
- BC25declaration changed
- BC262 procedures added, 1 procedures changed
- BC27unchanged
- BC283 events added, 1 procedures added
- BC291 events added
- BC302 procedures added, 1 procedures removed
Neighbourhood 19 connected objects and pages
Base Application · Microsoft.Sales.History · BC23-30 · source at 4e6a307c · facts from BC29
Properties
| Property | Value |
|---|---|
| TableNo | Sales Invoice Header |
| Permissions | TableData “Sales Invoice Header” = rm, TableData “Sales Cr.Memo Header” = rm |
Events published
OnAfterCreateCopyDocument(var SalesHeader: Record "Sales Header"; var SalesInvoiceHeader: Record "Sales Invoice Header")(integration): Raised after creating a copy document from a posted sales invoice.OnBeforeTestIfDropShipmentDocument(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean)+ BC28 (integration): Raised before testing whether to drop shipment document exists for the posted sales invoice.OnAfterIsCommentLine(SalesInvoiceLine: Record "Sales Invoice Line"; var Result: Boolean)(integration): Raised after determining whether a sales invoice line is a comment line.OnAfterTestCorrectInvoiceIsAllowed(var SalesInvoiceHeader: Record "Sales Invoice Header"; Cancelling: Boolean)(integration): Raised after testing whether the invoice correction or cancellation is allowed.OnAfterTestSalesLineType(SalesInvoiceLine: Record "Sales Invoice Line"; var IsHandled: Boolean)(integration): Raised after testing whether the sales invoice line type is allowed for correction.OnAfterCreateCorrSalesInvoice(var SalesHeader: Record "Sales Header"; var SalesInvoiceHeader: Record "Sales Invoice Header")(integration): Raised after creating a corrective sales invoice from a posted invoice.OnAfterCreateCorrectiveSalesCrMemo(SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header"; var CancellingOnly: Boolean)(integration): Raised after creating a corrective sales credit memo from a posted invoice.- subscribers: Codeunit 5579 “Digital Voucher Impl.” CopyDigitalVoucherOnAfterCreateCorrectiveSalesCrMemo
OnAfterUpdateSalesOrderLineInvoicedQuantity(var SalesLine: Record "Sales Line"; CancelledQuantity: Decimal; CancelledQtyBase: Decimal)(integration): Raised after updating the invoiced quantity on a sales order line during cancellation.OnBeforeCreateCorrectiveSalesCrMemo(var SalesInvoiceHeader: Record "Sales Invoice Header")(integration): Raised before creating a corrective sales credit memo from a posted invoice.OnBeforeCreateCreditMemoCopyDocument(var SalesInvoiceHeader: Record "Sales Invoice Header")(integration): Raised before creating a credit memo copy document from a posted invoice.OnCreateCreditMemoCopyDocumentOnBeforeConfirm(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header"; var ConfirmQuestion: Text)+ BC28 (integration): Raised before confirming the creation of a corrective credit memo for an invoice posted from a sales order.OnBeforeSalesHeaderInsert(var SalesHeader: Record "Sales Header"; var SalesInvoiceHeader: Record "Sales Invoice Header"; CancellingOnly: Boolean)(integration): Raised before inserting the sales header during invoice correction.OnBeforeSetTrackInfoForCancellation(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean)(integration): Raised before setting tracking information for invoice cancellation.OnBeforeTestIfAnyFreeNumberSeries(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean)(integration): Raised before testing whether there are free number series for the correction.OnHasLineDiscountSetup(SalesReceivablesSetup: Record "Sales & Receivables Setup"; var Result: Boolean)(integration): Raised to determine whether line discount setup is configured.OnBeforeTestInventoryPostingSetup(SalesInvoiceLine: Record "Sales Invoice Line"; var IsHandled: Boolean)(integration): Raised before testing inventory posting setup for the sales invoice line.OnBeforeUpdateSalesOrderLineInvoicedQuantity(var SalesLine: Record "Sales Line"; CancelledQuantity: Decimal; CancelledQtyBase: Decimal; var IsHandled: Boolean)(integration): Raised before updating the invoiced quantity on a sales order line during cancellation.OnUpdateSalesOrderLinePrepmtAmountOnBeforeUpdatePrepmtAmounts(SalesInvoiceLine: Record "Sales Invoice Line"; var SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"; Currency: Record Currency; var IsHandled: Boolean)+ BC29 (integration): Raised before updating prepayment amounts on a sales order line during correction.OnCreateCreditMemoOnBeforePageRun(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)(integration): Raised before opening the credit memo page during invoice correction.OnCreateCreditMemoOnBeforePostedPageRun(var SalesCrMemoHeader: Record "Sales Cr.Memo Header"; var IsHandled: Boolean)(integration): Raised before opening the posted credit memo page during invoice correction.OnBeforeUnapplyCostApplication(InvNo: Code[20]; var IsHandled: Boolean)(integration): Raised before unapplying cost applications for the invoice.OnTestSalesLinesOnAfterCalcShippedQtyNoReturned(SalesInvoiceLine: Record "Sales Invoice Line"; var ShippedQtyNoReturned: Decimal)(integration): Raised after calculating the shipped quantity not returned during sales line validation.OnOnRunOnAfterUpdateSalesOrderLinesFromCancelledInvoice(var Rec: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header")(integration): Raised after updating sales order lines from a cancelled invoice during the OnRun trigger.OnBeforeTestIfInvoiceIsPaid(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean)(integration): Raised before testing whether the invoice has been paid.OnCreateCorrectiveCreditMemoOnBeforePageRun(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)(integration): Raised before opening the corrective credit memo page from a notification action.OnBeforeTestVATPostingSetup(SalesInvoiceLine: Record "Sales Invoice Line"; var IsHandled: Boolean)(integration): Raised before testing VAT posting setup for the sales invoice line.OnBeforeErrorHelperHeader(HeaderErrorType: Enum "Correct Sales Inv. Error Type"; SalesInvoiceHeader: Record "Sales Invoice Header"; CancellingOnly: Boolean)(integration): Raised before raising a header-level error during invoice correction validation.OnBeforeTestIfInvoiceIsCorrectedOnce(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean)(integration): Raised before testing whether the invoice has already been corrected.OnBeforeWasNotCancelled(InvNo: Code[20]; var Result: Boolean; var IsHandled: Boolean)(integration): Raised before checking whether the invoice was not cancelled.OnRunOnBeforePostCorrectiveSalesCrMemo(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header"; var IsHandled: Boolean; var SuppressCommit: Boolean)+ BC24 − BC24 (integration): Raised before posting the corrective sales credit memo during the OnRun trigger.OnBeforeTestWMSLocation(var SalesInvoiceLine: Record "Sales Invoice Line"; var IsHandled: Boolean)(integration): Raised before testing warehouse management system location for the sales invoice line.OnBeforeCreateAndProcessJobPlanningLines(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)(integration): Raised before creating and processing project planning lines during invoice correction.OnTestGenPostingSetupOnBeforeTestTypeItem(SalesInvoiceLine: Record "Sales Invoice Line"; var IsHandled: Boolean)(integration): Raised before testing general posting setup for item type lines.OnBeforeUpdateSalesOrderLinesFromCancelledInvoice(SalesInvoiceHeaderNo: Code[20]; var IsHandled: Boolean)+ BC24 (integration): Raised before updating sales order lines from a cancelled invoice.OnBeforeUpdateSalesOrderLinesFromCreditMemo(var SalesInvoiceLine: Record "Sales Invoice Line"; var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var IsHandled: Boolean)+ BC28 (integration): Raised before updating sales order lines from a credit memo.OnCreateJobPlanningLineOnAfterInitFromJobPlanningLine(var ToJobPlanningLine: Record "Job Planning Line"; FromJobPlanningLine: Record "Job Planning Line"; SalesLine: Record "Sales Line")+ BC24 (integration): Raised after initializing a project planning line from another project planning line during correction.
Procedures
CancelPostedInvoice(var SalesInvoiceHeader: Record "Sales Invoice Header"): Boolean: Cancels the posted sales invoice by creating and posting a corrective credit memo.CreateCreditMemoCopyDocument(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header"): Boolean: Creates a credit memo document as a copy of the posted sales invoice without posting it.CreateCorrectiveCreditMemo(var InvoiceNotification: Notification): Creates a corrective credit memo from a notification action triggered on a posted sales invoice.ShowAppliedEntries(var InvoiceNotification: Notification): Shows the applied customer ledger entries for the posted sales invoice referenced in the notification.SkipCorrectiveCreditMemo(var InvoiceNotification: Notification): Dismisses the corrective credit memo notification without taking any action.CancelPostedInvoiceCreateNewInvoice(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesHeader: Record "Sales Header"): Cancels the posted sales invoice and creates a new sales invoice as a copy for correction.TestCorrectInvoiceIsAllowed(var SalesInvoiceHeader: Record "Sales Invoice Header"; Cancelling: Boolean): Tests whether the posted sales invoice can be corrected or canceled by checking payment status, customer blocks, and other conditions.FindItemLedgEntries(var ItemLedgEntry: Record "Item Ledger Entry"; InvNo: Code[20]): Finds all item ledger entries associated with the specified posted sales invoice.ErrorHelperHeader(HeaderErrorType: Enum "Correct Sales Inv. Error Type"; SalesInvoiceHeader: Record "Sales Invoice Header")Δ BC26: Raises an error message based on the header error type encountered during invoice correction validation.UpdateSalesOrderLineIfExist(SalesCreditMemoNo: Code[20])(internal): Updates the related sales order lines when a credit memo exists for the specified credit memo number. Credit memo quantities are converted to the unit of measure of each sales order line.
Plus 45 local procedures.
Triggers
OnRun
Relations
- runs on Table 112 “Sales Invoice Header”
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 408 “DimensionManagement” (5 calls:
TestCustomerDimension → CheckDimValuePosting,TestDimensionOnHeader → CheckDimIDComb,TestGLAccount → CheckDimValuePosting, …) - Codeunit 6620 “Copy Document Mgt.” (3 calls:
CreateCopyDocument → CopySalesDocForInvoiceCancelling,CreateCopyDocument → SetPropertiesForCorrectiveCreditMemo,CreateCopyDocument → SetPropertiesForInvoiceCorrection) - Codeunit 22 “Item Jnl.-Post Line” (2 calls:
UnapplyCostApplication → RedoApplications,UnapplyCostApplication → UnApply) - Codeunit 5817 “Undo Posting Management” (2 calls:
UpdateSalesOrderLinesFromCancelledInvoice → RevertPostedItemTracking,UpdateSalesOrderLinesFromCreditMemo → RevertPostedItemTracking) - Page 44 “Sales Credit Memo” (2 calls:
CreateCorrectiveCreditMemo → (object),CreateCreditMemo → (object)) - Page 456 “No. Series” (2 calls:
OnRun → (object),TryPeekNextNo → (object)) - Codeunit 11 “Gen. Jnl.-Check Line” (1 call:
TestIfPostingIsAllowed → DateNotAllowed) - Codeunit 1511 “Notification Lifecycle Mgt.” (1 call:
ShowInvoiceAppliedNotification → SendNotification) - Codeunit 5402 “Unit of Measure Management” (1 call:
UpdateSalesOrderLinesFromCreditMemo → CalcQtyFromBase) - Codeunit 700 “Page Management” (1 call:
CreateCreditMemo → PageRun) - Codeunit 80 “Sales-Post” (1 call:
OnRun → (object)) - Page 61 “Applied Customer Entries” (1 call:
ShowAppliedEntries → (object))
Called by
- Codeunit 1322 “Correct PstdSalesInv (Yes/No)” (4 calls:
CancelPostedInvoice → CancelPostedInvoice,CancelPostedInvoiceAndOpenNewSalesInvoice → CancelPostedInvoiceCreateNewInvoice,CancelPostedInvoiceAndOpenSalesOrder → CancelPostedInvoice, …) - Page 20012 “APIV1 - Sales Invoices” (3 calls:
CancelInvoice → (object),CheckInvoiceCanBeCanceled → TestCorrectInvoiceIsAllowed,MakeCorrectiveCreditMemo → CreateCreditMemoCopyDocument) - Page 30012 “APIV2 - Sales Invoices” (3 calls:
CancelInvoice → (object),CheckInvoiceCanBeCanceled → TestCorrectInvoiceIsAllowed,MakeCorrectiveCreditMemo → CreateCreditMemoCopyDocument) - Codeunit 1323 “Cancel PstdSalesInv (Yes/No)” (2 calls:
CancelInvoice → CancelPostedInvoice,CancelInvoice → TestCorrectInvoiceIsAllowed) - Codeunit 80 “Sales-Post” (1 call:
UpdateSalesOrderLineIfExist → UpdateSalesOrderLineIfExist) - Table 36 “Sales Header” (1 call:
UpdateSalesOrderLineIfExist → UpdateSalesOrderLineIfExist)
Recent changes
- 2026-12-03 #11156 Allow controlled changes to item tracking codes (main, BC30, feature)
- 2026-11-26 #14413 [29.x][ALL-E] Posting a Sales Credit Memo with a different Unit of Measure does not convert the quantity before updating the originating Sales Order (Blanket Sales Order is updated correctly) (releases/29.x, BC29, fix)
- 2026-11-18 #13917 [Main][ALL-E] Posting a Sales Credit Memo with a different Unit of Measure does not convert the quantity before updating the originating Sales Order (Blanket Sales Order is updated correctly) (main, BC30, fix)
- 2026-11-06 #11256 [main] Add setup option to restore Sales and Purchase Order quantities when posting returns (main, BC30, feature)
- 2026-11-03 #13547 [29.X]-Sales Order line quantities are incorrectly updated after posting a Return Order linked to a Posted Sales Invoice via Applies-to Doc. No. on a Credit Memo (releases/29.x, BC29, fix)
- 2026-11-02 #13417 [Master]-Sales Order line quantities are incorrectly updated after posting a Return Order linked to a Posted Sales Invoice via Applies-to Doc. No. on a Credit Memo. (main, BC30, fix)
- 2026-10-19 #12186 Set several fields in one ModifyAll call (main, BC30, performance)
- 2026-09-02 #10902 [Extensibility Request] issue 30424: add prepayment update event (main, BC30, feature)
- 2026-08-11 #10083 [main]- Negative Shipped and Invoiced Quantities appear on Sales Order Lines after using the Copy Document from a Sales Credit Memo. (main, BC30, fix)
- 2026-07-15 #9440 [Extensibility Request] issue 30331: add event to adjust corrective credit memo confirmation text (main, BC30, feature)
Countries that replace it
Possibly related
No source states these links: they share an object, a model read them, or a person found the same subject.
- Correct or cancel a posted sales invoice — possibly related: Documents correcting or canceling posted sales invoices with automatic corrective credit memo creation. (model-linked)
- Standard Sales Credit Memo report — possibly related: Documents standard sales credit memo report generation for posted credit memos. (model-linked)
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: "Correct Posted Sales Invoice"), then bcatlas_get_procedure_body or bcatlas_get_neighbors on the returned id.