---
id: object/codeunit/5477
type: object
title: Codeunit 5477 "Sales Invoice Aggregator"
summary: Codeunit 5477 "Sales Invoice Aggregator" in Base Application (Microsoft.Integration.Entity). 21 public procedures, 2 events, 21 event subscribers. Present since at least BC23, still in BC30, changed in BC24, BC27.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "27"
  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: 7ca1bda7cf6fef688c68c9fb5d1e0ffc3043b522eb6d08f6d9aabeac8646c9d3
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Integration/Entity/SalesInvoiceAggregator.Codeunit.al
    title: src/Layers/W1/BaseApp/Integration/Entity/SalesInvoiceAggregator.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 5477
name: Sales Invoice Aggregator
namespace: Microsoft.Integration.Entity
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "27"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 71
  events: 2
  subscribers: 21
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 11
  called_by: 21
  implements: 0
---

# Codeunit 5477 "Sales Invoice Aggregator"

> Codeunit 5477 "Sales Invoice Aggregator" in Base Application (Microsoft.Integration.Entity). 21 public procedures, 2 events, 21 event subscribers. Present since at least BC23, still in BC30, changed in BC24, BC27.

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

## Properties

| Property | Value |
|---|---|
| Permissions | tabledata "Sales Invoice Header" = rimd, tabledata "Sales Invoice Entity Aggregate" = rimd |

## Events published

- `OnBeforeSetStatusOptionFromSalesInvoiceHeader(var SalesInvoiceHeader: Record "Sales Invoice Header"; var SalesInvoiceEntityAggregate: Record "Sales Invoice Entity Aggregate"; var IsHandled: Boolean)` (integration)
- `OnBeforeTransferRecordIDs(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)` (integration)

## Event subscriptions

- OnAfterInsertSalesHeader subscribes to Table "Sales Header" OnAfterInsertEvent
- OnAfterModifySalesHeader subscribes to Table "Sales Header" OnAfterModifyEvent
- OnAfterDeleteSalesHeader subscribes to Table "Sales Header" OnAfterDeleteEvent
- OnAfterResetRecalculateInvoiceDisc subscribes to Codeunit "Sales - Calc Discount By Type" OnAfterResetRecalculateInvoiceDisc
- OnAfterInsertSalesLine subscribes to Table "Sales Line" OnAfterInsertEvent
- OnAfterModifySalesLine subscribes to Table "Sales Line" OnAfterModifyEvent
- OnAfterDeleteSalesLine subscribes to Table "Sales Line" OnAfterDeleteEvent
- OnAfterInsertSalesInvoiceHeader subscribes to Table "Sales Invoice Header" OnAfterInsertEvent
- OnAfterModifySalesInvoiceHeader subscribes to Table "Sales Invoice Header" OnAfterModifyEvent
- OnAfterRenameSalesInvoiceHeader subscribes to Table "Sales Invoice Header" OnAfterRenameEvent
- OnAfterDeleteSalesInvoiceHeader subscribes to Table "Sales Invoice Header" OnAfterDeleteEvent
- OnAfterCalculateSalesDiscountOnSalesHeader subscribes to Codeunit "Sales-Calc. Discount" OnAfterCalcSalesDiscount
- OnAfterInsertCustomerLedgerEntry subscribes to Table "Cust. Ledger Entry" OnAfterInsertEvent
- OnAfterModifyCustomerLedgerEntry subscribes to Table "Cust. Ledger Entry" OnAfterModifyEvent
- OnAfterRenameCustomerLedgerEntry subscribes to Table "Cust. Ledger Entry" OnAfterRenameEvent
- OnAfterDeleteCustomerLedgerEntry subscribes to Table "Cust. Ledger Entry" OnAfterDeleteEvent
- OnAfterInsertCancelledDocument subscribes to Table "Cancelled Document" OnAfterInsertEvent
- OnAfterModifyCancelledDocument subscribes to Table "Cancelled Document" OnAfterModifyEvent
- OnAfterRenameCancelledDocument subscribes to Table "Cancelled Document" OnAfterRenameEvent
- OnAfterDeleteCancelledDocument subscribes to Table "Cancelled Document" OnAfterDeleteEvent
- OnBeforeSalesInvHeaderInsert subscribes to Codeunit "Sales-Post" OnBeforeSalesInvHeaderInsert

## Procedures

- `PropagateOnInsert(var SalesInvoiceEntityAggregate: Record "Sales Invoice Entity Aggregate"; var TempFieldBuffer: Record "Field Buffer" temporary)`
- `PropagateOnModify(var SalesInvoiceEntityAggregate: Record "Sales Invoice Entity Aggregate"; var TempFieldBuffer: Record "Field Buffer" temporary)`
- `ChangeOnlyContainsWhitelistedFields(var TempFieldBuffer: Record "Field Buffer"): Boolean`
- `PropagateOnDelete(var SalesInvoiceEntityAggregate: Record "Sales Invoice Entity Aggregate")`
- `UpdateAggregateTableRecords()`
- `GetSalesInvoiceHeaderId(var SalesInvoiceHeader: Record "Sales Invoice Header"): Guid`
- `GetSalesInvoiceHeaderFromId(Id: text; var SalesInvoiceHeader: Record "Sales Invoice Header"): Boolean`
- `SetTaxGroupIdAndCode(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate"; TaxGroupCode: Code[20]; VATProductPostingGroupCode: Code[20]; VATIdentifier: Code[20])`
- `SetItemVariantId(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate"; ItemNo: Code[20]; VariantCode: Code[20])`
- `UpdateUnitOfMeasure(var Item: Record Item; JSONUnitOfMeasureTxt: Text)`
- `RedistributeInvoiceDiscounts(var SalesInvoiceEntityAggregate: Record "Sales Invoice Entity Aggregate")`
- `LoadLines(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate"; DocumentIdFilter: Text)`
- `TransferFromSalesLineToAggregateLine(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate"; var SalesLine: Record "Sales Line"; DocumentId: Guid; PricesIncludingVAT: Boolean)`
- `PropagateInsertLine(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate"; var TempFieldBuffer: Record "Field Buffer" temporary)`
- `PropagateModifyLine(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate"; var TempFieldBuffer: Record "Field Buffer" temporary)`
- `PropagateDeleteLine(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate")`
- `PropagateMultipleLinesUpdate(var TempNewSalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate" temporary)`
- `UpdateInvoiceDiscountAmount(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate")`
- `VerifyCanUpdateUOM(var SalesInvoiceLineAggregate: Record "Sales Invoice Line Aggregate")`
- `FixInvoicesCreatedFromOrders()`
- `GetIdFromDocumentIdAndSequence(DocumentId: Guid; Sequence: Integer): Text[50]`

Plus 27 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 5465 "Graph Mgt - General Tools"](../codeunit/5465.md) (26 calls: `CheckValidLineRecord → IsApiEnabled`, `GetIdFromDocumentIdAndSequence → StripBrackets`, `OnAfterCalculateSalesDiscountOnSalesHeader → IsApiEnabled`, …)
- [Codeunit 10 "Type Helper"](../codeunit/10.md) (4 calls: `PropagateOnInsert → TransferFieldsWithValidate`, `PropagateOnModifyToSalesHeader → TransferFieldsWithValidate`, `PropagateOnModifyToSalesInvoiceHeader → TransferFieldsWithValidate`, …)
- [Codeunit 57 "Document Totals"](../codeunit/57.md) (2 calls: `AssignTotalsFromSalesInvoiceLine → CalculatePostedSalesInvoiceTotals`, `AssignTotalsFromSalesLine → CalculateSalesTotals`)
- [Codeunit 9999 "Upgrade Tag"](../codeunit/9999.md) (2 calls: `FixInvoicesCreatedFromOrders → HasUpgradeTag`, `FixInvoicesCreatedFromOrders → SetUpgradeTag`)
- [Codeunit 1409 "Sales Inv. Header - Edit"](../codeunit/1409.md) (1 call: `PropagateOnModifyToSalesInvoiceHeader → (object)`)
- [Codeunit 5470 "Graph Collection Mgt - Item"](../codeunit/5470.md) (1 call: `UpdateUnitOfMeasure → UpdateOrCreateItemUnitOfMeasureFromSalesDocument`)
- [Codeunit 5506 "Graph Mgt - Sales Quote Buffer"](../codeunit/5506.md) (1 call: `PropagateMultipleLinesUpdate → GetFieldSetBufferWithAllFieldsSet`)
- [Codeunit 5532 "Disable Aggregate Table Update"](../codeunit/5532.md) (1 call: `CheckUpdatesDisabled → OnGetAggregateTablesUpdateEnabled`)
- [Codeunit 56 "Sales - Calc Discount By Type"](../codeunit/56.md) (1 call: `RedistributeInvoiceDiscounts → (object)`)
- [Codeunit 9994 "API Data Upgrade"](../codeunit/9994.md) (1 call: `UpdateAggregateTableRecords → CountRecordsAndCommit`)
- [Codeunit 9998 "Upgrade Tag Definitions"](../codeunit/9998.md) (1 call: `FixInvoicesCreatedFromOrders → GetFixAPISalesInvoicesCreatedFromOrders`)

## Called by

- [Page 20012 "APIV1 - Sales Invoices"](../page/20012.md) (12 calls: `Cancel → GetSalesInvoiceHeaderId`, `CancelAndSend → GetSalesInvoiceHeaderId`, `GetPostedInvoice → GetSalesInvoiceHeaderFromId`, …)
- [Page 30012 "APIV2 - Sales Invoices"](../page/30012.md) (12 calls: `Cancel → GetSalesInvoiceHeaderId`, `CancelAndSend → GetSalesInvoiceHeaderId`, `GetPostedInvoice → GetSalesInvoiceHeaderFromId`, …)
- [Codeunit 5508 "Graph Mgt - Sal. Cr. Memo Buf."](../codeunit/5508.md) (5 calls: `LoadSalesCreditMemoLines → GetIdFromDocumentIdAndSequence`, `LoadSalesCreditMemoLines → SetItemVariantId`, `LoadSalesCreditMemoLines → SetTaxGroupIdAndCode`, …)
- [Page 20043 "APIV1 - Sales Invoice Lines"](../page/20043.md) (4 calls: `OnDeleteRecord → PropagateDeleteLine`, `OnFindRecord → LoadLines`, `OnInsertRecord → PropagateInsertLine`, …)
- [Page 30043 "APIV2 - Sales Invoice Lines"](../page/30043.md) (4 calls: `OnDeleteRecord → PropagateDeleteLine`, `OnFindRecord → LoadLines`, `OnInsertRecord → PropagateInsertLine`, …)
- [Codeunit 5496 "Graph Mgt - Sales Order Buffer"](../codeunit/5496.md) (3 calls: `TransferFromSalesLine → GetIdFromDocumentIdAndSequence`, `TransferFromSalesLine → SetItemVariantId`, `TransferFromSalesLine → SetTaxGroupIdAndCode`)
- [Codeunit 5503 "Graph Mgt - Attachment Buffer"](../codeunit/5503.md) (3 calls: `FindParentDocumentSafe → GetSalesInvoiceHeaderFromId`, `FindParentDocumentWithDocumentTypeSafe → GetSalesInvoiceHeaderFromId`, `GetDocumentId → GetSalesInvoiceHeaderId`)
- [Codeunit 5506 "Graph Mgt - Sales Quote Buffer"](../codeunit/5506.md) (3 calls: `TransferFromSalesLine → GetIdFromDocumentIdAndSequence`, `TransferFromSalesLine → SetItemVariantId`, `TransferFromSalesLine → SetTaxGroupIdAndCode`)
- [Codeunit 5511 "Graph Mgt - Purch. Cr. Memo"](../codeunit/5511.md) (2 calls: `LoadPurchaseCreditMemoLines → GetIdFromDocumentIdAndSequence`, `TransferFromPurchaseLine → GetIdFromDocumentIdAndSequence`)
- [Codeunit 5529 "Purch. Inv. Aggregator"](../codeunit/5529.md) (2 calls: `LoadPurchaseInvoiceLines → GetIdFromDocumentIdAndSequence`, `TransferFromPurchaseLine → GetIdFromDocumentIdAndSequence`)
- [Codeunit 9994 "API Data Upgrade"](../codeunit/9994.md) (2 calls: `OnRun → FixInvoicesCreatedFromOrders`, `OnRun → UpdateAggregateTableRecords`)
- [Table 81 "Gen. Journal Line"](../table/81.md) (2 calls: `UpdateAppliesToInvoiceID → GetSalesInvoiceHeaderId`, `UpdateAppliesToInvoiceNo → GetSalesInvoiceHeaderFromId`)
- [Codeunit 104000 "Upgrade - BaseApp"](../codeunit/104000.md) (1 call: `UpgradeInvoicesCreatedFromOrders → FixInvoicesCreatedFromOrders`)
- [Codeunit 5450 "Sales Invoice PDF Doc.Handler"](../codeunit/5450.md) (1 call: `GeneratePdfBlobWithDocumentType → GetSalesInvoiceHeaderFromId`)
- [Codeunit 5467 "PDF Document Management"](../codeunit/5467.md) (1 call: `GeneratePdf → GetSalesInvoiceHeaderFromId`)
- [Codeunit 5475 "Graph Mgt - Sales Invoice"](../codeunit/5475.md) (1 call: `HandleApiSetup → UpdateAggregateTableRecords`)
- [Codeunit 5497 "Graph Mgt - Purch Order Buffer"](../codeunit/5497.md) (1 call: `TransferFromPurchaseLine → GetIdFromDocumentIdAndSequence`)
- [Page 20028 "APIV1 - Sales Orders"](../page/20028.md) (1 call: `ShipAndInvoice → GetSalesInvoiceHeaderId`)
- [Page 20038 "APIV1 - Sales Credit Memos"](../page/20038.md) (1 call: `SetInvoiceId → GetSalesInvoiceHeaderId`)
- [Page 30028 "APIV2 - Sales Orders"](../page/30028.md) (1 call: `ShipAndInvoice → GetSalesInvoiceHeaderId`)
- [Page 30038 "APIV2 - Sales Credit Memos"](../page/30038.md) (1 call: `SetInvoiceId → GetSalesInvoiceHeaderId`)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24, BC27

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