---
id: object/codeunit/5529
type: object
title: Codeunit 5529 "Purch. Inv. Aggregator"
summary: Codeunit 5529 "Purch. Inv. Aggregator" in Base Application (Microsoft.Integration.Entity). 18 public procedures, 21 event subscribers. Present since at least BC23, still in BC30, changed in 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: 900a79374801440a326dc7f05fcd0e06e2b26842a262b4142e1ae95ef2594702
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Integration/Entity/PurchInvAggregator.Codeunit.al
    title: src/Layers/W1/BaseApp/Integration/Entity/PurchInvAggregator.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: 5529
name: Purch. Inv. 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:
  - "27"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 63
  events: 0
  subscribers: 21
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 10
  called_by: 15
  implements: 0
---

# Codeunit 5529 "Purch. Inv. Aggregator"

> Codeunit 5529 "Purch. Inv. Aggregator" in Base Application (Microsoft.Integration.Entity). 18 public procedures, 21 event subscribers. Present since at least BC23, still in BC30, changed in BC27.

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

## Properties

| Property | Value |
|---|---|
| Permissions | tabledata "Purch. Inv. Header" = rimd, tabledata "Purch. Inv. Entity Aggregate" = rimd |

## Event subscriptions

- OnAfterInsertPurchaseHeader subscribes to Table "Purchase Header" OnAfterInsertEvent
- OnAfterModifyPurchaseHeader subscribes to Table "Purchase Header" OnAfterModifyEvent
- OnAfterDeletePurchaseHeader subscribes to Table "Purchase Header" OnAfterDeleteEvent
- OnAfterResetRecalculateInvoiceDisc subscribes to Codeunit "Purch - Calc Disc. By Type" OnAfterResetRecalculateInvoiceDisc
- OnAfterInsertPurchaseLine subscribes to Table "Purchase Line" OnAfterInsertEvent
- OnAfterModifyPurchaseLine subscribes to Table "Purchase Line" OnAfterModifyEvent
- OnAfterDeletePurchaseLine subscribes to Table "Purchase Line" OnAfterDeleteEvent
- OnAfterInsertPurchaseInvoiceHeader subscribes to Table "Purch. Inv. Header" OnAfterInsertEvent
- OnAfterModifyPurchaseInvoiceHeader subscribes to Table "Purch. Inv. Header" OnAfterModifyEvent
- OnAfterRenamePurchaseInvoiceHeader subscribes to Table "Purch. Inv. Header" OnAfterRenameEvent
- OnAfterDeletePurchaseInvoiceHeader subscribes to Table "Purch. Inv. Header" OnAfterDeleteEvent
- OnAfterCalculatePurchaseDiscountOnPurchaseHeader subscribes to Codeunit "Purch.-Calc.Discount" OnAfterCalcPurchaseDiscount
- OnAfterInsertVendorLedgerEntry subscribes to Table "Vendor Ledger Entry" OnAfterInsertEvent
- OnAfterModifyVendorLedgerEntry subscribes to Table "Vendor Ledger Entry" OnAfterModifyEvent
- OnAfterRenameVendorLedgerEntry subscribes to Table "Vendor Ledger Entry" OnAfterRenameEvent
- OnAfterDeleteVendorLedgerEntry subscribes to Table "Vendor 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
- OnBeforePurchInvHeaderInsert subscribes to Codeunit "Purch.-Post" OnBeforePurchInvHeaderInsert

## Procedures

- `PropagateOnInsert(var PurchInvEntityAggregate: Record "Purch. Inv. Entity Aggregate"; var TempFieldBuffer: Record "Field Buffer" temporary)`
- `PropagateOnModify(var PurchInvEntityAggregate: Record "Purch. Inv. Entity Aggregate"; var TempFieldBuffer: Record "Field Buffer" temporary)`
- `PropagateOnDelete(var PurchInvEntityAggregate: Record "Purch. Inv. Entity Aggregate")`
- `UpdateAggregateTableRecords()`
- `GetPurchaseInvoiceHeaderId(var PurchInvHeader: Record "Purch. Inv. Header"): Guid`
- `GetPurchaseInvoiceHeaderFromId(Id: Text; var PurchInvHeader: Record "Purch. Inv. Header"): Boolean`
- `UpdateUnitOfMeasure(var Item: Record Item; JSONUnitOfMeasureTxt: Text)`
- `RedistributeInvoiceDiscounts(var PurchInvEntityAggregate: Record "Purch. Inv. Entity Aggregate")`
- `LoadLines(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate"; DocumentIdFilter: Text)`
- `PropagateInsertLine(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate"; var TempFieldBuffer: Record "Field Buffer" temporary)`
- `PropagateModifyLine(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate"; var TempFieldBuffer: Record "Field Buffer" temporary)`
- `PropagateDeleteLine(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate")`
- `UpdateLineAmountsFromPurchaseLine(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate")`
- `SetItemVariantId(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate"; ItemNo: Code[20]; VariantCode: Code[20])`
- `UpdateInvoiceDiscountAmount(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate")`
- `VerifyCanUpdateUOM(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate")`
- `FixInvoicesCreatedFromOrders()`
- `SetTaxGroupIdAndCode(var PurchInvLineAggregate: Record "Purch. Inv. Line Aggregate"; TaxGroupCode: Code[20]; VATProductPostingGroupCode: Code[20]; VATIdentifier: Code[20])`

Plus 24 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) (25 calls: `CheckValidLineRecord → IsApiEnabled`, `ModifyTotalsPurchaseLine → IsApiEnabled`, `OnAfterCalculatePurchaseDiscountOnPurchaseHeader → IsApiEnabled`, …)
- [Codeunit 5477 "Sales Invoice Aggregator"](../codeunit/5477.md) (2 calls: `LoadPurchaseInvoiceLines → GetIdFromDocumentIdAndSequence`, `TransferFromPurchaseLine → GetIdFromDocumentIdAndSequence`)
- [Codeunit 57 "Document Totals"](../codeunit/57.md) (2 calls: `AssignTotalsFromPurchaseInvoiceLine → CalculatePostedPurchInvoiceTotals`, `AssignTotalsFromPurchaseLine → CalculatePurchaseTotals`)
- [Codeunit 9999 "Upgrade Tag"](../codeunit/9999.md) (2 calls: `FixInvoicesCreatedFromOrders → HasUpgradeTag`, `FixInvoicesCreatedFromOrders → SetUpgradeTag`)
- [Codeunit 5470 "Graph Collection Mgt - Item"](../codeunit/5470.md) (1 call: `UpdateUnitOfMeasure → UpdateOrCreateItemUnitOfMeasureFromSalesDocument`)
- [Codeunit 5532 "Disable Aggregate Table Update"](../codeunit/5532.md) (1 call: `CheckUpdatesDisabled → OnGetAggregateTablesUpdateEnabled`)
- [Codeunit 66 "Purch - Calc Disc. By Type"](../codeunit/66.md) (1 call: `RedistributeInvoiceDiscounts → (object)`)
- [Codeunit 701 "Data Type Management"](../codeunit/701.md) (1 call: `TransferFieldsWithValidate → GetRecordRef`)
- [Codeunit 9994 "API Data Upgrade"](../codeunit/9994.md) (1 call: `UpdateAggregateTableRecords → CountRecordsAndCommit`)
- [Codeunit 9998 "Upgrade Tag Definitions"](../codeunit/9998.md) (1 call: `FixInvoicesCreatedFromOrders → GetFixAPIPurchaseInvoicesCreatedFromOrders`)

## Called by

- [Page 20042 "APIV1 - Purchase Invoices"](../page/20042.md) (8 calls: `OnAfterGetRecord → RedistributeInvoiceDiscounts`, `OnDeleteRecord → PropagateOnDelete`, `OnInsertRecord → PropagateOnInsert`, …)
- [Page 30042 "APIV2 - Purchase Invoices"](../page/30042.md) (8 calls: `OnAfterGetRecord → RedistributeInvoiceDiscounts`, `OnDeleteRecord → PropagateOnDelete`, `OnInsertRecord → PropagateOnInsert`, …)
- [Codeunit 5511 "Graph Mgt - Purch. Cr. Memo"](../codeunit/5511.md) (6 calls: `LoadPurchaseCreditMemoLines → SetItemVariantId`, `LoadPurchaseCreditMemoLines → SetTaxGroupIdAndCode`, `TransferFromPurchaseLine → SetItemVariantId`, …)
- [Page 20047 "APIV1 - Purchase Invoice Lines"](../page/20047.md) (4 calls: `OnDeleteRecord → PropagateDeleteLine`, `OnFindRecord → LoadLines`, `OnInsertRecord → PropagateInsertLine`, …)
- [Page 30047 "APIV2 - Purchase Invoice Lines"](../page/30047.md) (4 calls: `OnDeleteRecord → PropagateDeleteLine`, `OnFindRecord → LoadLines`, `OnInsertRecord → PropagateInsertLine`, …)
- [Codeunit 5503 "Graph Mgt - Attachment Buffer"](../codeunit/5503.md) (3 calls: `FindParentDocumentSafe → GetPurchaseInvoiceHeaderFromId`, `FindParentDocumentWithDocumentTypeSafe → GetPurchaseInvoiceHeaderFromId`, `GetDocumentId → GetPurchaseInvoiceHeaderId`)
- [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 → GetPurchaseInvoiceHeaderId`, `UpdateAppliesToInvoiceNo → GetPurchaseInvoiceHeaderFromId`)
- [Codeunit 104000 "Upgrade - BaseApp"](../codeunit/104000.md) (1 call: `UpgradeInvoicesCreatedFromOrders → FixInvoicesCreatedFromOrders`)
- [Codeunit 5446 "Purch. Invoice PDF Doc.Handler"](../codeunit/5446.md) (1 call: `GeneratePdfBlobWithDocumentType → GetPurchaseInvoiceHeaderFromId`)
- [Codeunit 5467 "PDF Document Management"](../codeunit/5467.md) (1 call: `GeneratePdf → GetPurchaseInvoiceHeaderFromId`)
- [Codeunit 5497 "Graph Mgt - Purch Order Buffer"](../codeunit/5497.md) (1 call: `TransferFromPurchaseLine → SetTaxGroupIdAndCode`)
- [Codeunit 5527 "Graph Mgt - Purchase Invoice"](../codeunit/5527.md) (1 call: `HandleApiSetup → UpdateAggregateTableRecords`)
- [Page 30066 "APIV2 - Purchase Orders"](../page/30066.md) (1 call: `ReceiveAndInvoice → GetPurchaseInvoiceHeaderId`)
- [Page 30083 "APIV2 - Purchase Credit Memos"](../page/30083.md) (1 call: `SetInvoiceId → GetPurchaseInvoiceHeaderId`)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: 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: "Purch. Inv. Aggregator")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
