---
id: change/bcapps/13725
type: change
title: "#13725 Reduce repeated ILE reads and JIT loads in average cost adjustment"
summary: Codeunit 5895 Inventory Adjustment reduces repeated database reads and JIT loads during average cost calculation by caching Item Ledger Entry data, loading required fields upfront, and removing ineffective LoadFields calls.
tier: official
language: en
tags:
  - performance
  - main
  - bc30
  - codeunit inventory adjustment
system: inventory
review:
  state: reviewed
  by: opus
  at: "2026-11-07T01:03:56.773Z"
  flags: []
generated:
  at: "2026-11-14T00:13:17.671Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 7d721539a02ead2ccb73ae84ffdb484967e663ca
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13725
    title: "microsoft/BCApps#13725: Reduce repeated ILE reads and JIT loads in average cost adjustment"
    date: "2026-11-06"
    commit: 7d721539a02ead2ccb73ae84ffdb484967e663ca
    t: null
    quote: null
links:
  learn: []
  objects:
    - object/codeunit/5895
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/design-details-average-cost
      title: Design details - Average cost
      label: possibly related
      why: Documents average cost calculation and cost adjustment mechanism in inventory.
      by: model
number: 13725
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13725
kind: pr
base_branch: main
major: "30"
merged_at: "2026-11-06T17:25:18Z"
author: alexei-dobriansky
author_type: User
community_contribution: false
labels:
  - "Ownership: Manual"
  - "Team: SCM"
change_class: code
change_kind: performance
behavior_change: false
breaking: false
files:
  count: 3
  additions: 99
  deletions: 33
  al: 3
apps:
  - Base Application
objects_touched:
  - key: codeunit/5895
    page: codeunit/5895
    type: codeunit
    id: 5895
    name: Inventory Adjustment
    app: Base Application
    status: modified
objects_unjoined:
  - path: src/Layers/APAC/BaseApp/Inventory/Costing/InventoryAdjustment.Codeunit.al
    status: modified
    reason: not-in-snapshot
obsoletions: []
backports:
  - number: 13800
    base: releases/29.x
    url: https://github.com/microsoft/BCApps/pull/13800
fixes_issues: []
work_items:
  - 658046
systems:
  - inventory
quote: null
joined_against:
  major: "30"
  commit: d2abc1d2ceae394331716c8183ef60e1534c2ce0
---

# #13725 Reduce repeated ILE reads and JIT loads in average cost adjustment

> Codeunit 5895 Inventory Adjustment reduces repeated database reads and JIT loads during average cost calculation by caching Item Ledger Entry data, loading required fields upfront, and removing ineffective LoadFields calls.

[Pull request](https://github.com/microsoft/BCApps/pull/13725) · merged into `main` (BC30) on 2026-11-06 by alexei-dobriansky · 3 files (+99 -33), 3 AL · performance · tier official · reviewed (checked by Opus)

## What changed

- Caches the immutable Positive field from Item Ledger Entry in a dictionary to eliminate repeated lookups
- Loads all required chain fields upfront in ExcludeAvgCostOnValuationDate and IsAvgCostException to prevent JIT loads
- Removes ineffective LoadFields calls in AvgValueEntriesToAdjustExist and CollectOpenValueEntries
- Adds missing fields to load lists: Applied Entry to Adjust and Valuation Date
- Improves performance for high-volume items where processing time grew quadratically with value entries

## AL objects touched

- [Codeunit 5895 "Inventory Adjustment"](../../objects/codeunit/5895.md), Base Application: modified
- `src/Layers/APAC/BaseApp/Inventory/Costing/InventoryAdjustment.Codeunit.al`: modified, not in the BC30 snapshot

## Also merged into

- [#13800](https://github.com/microsoft/BCApps/pull/13800) into `releases/29.x` on 2026-11-13

## Context

- Work items: AB#658046
- Labels: Ownership: Manual, Team: SCM
- Systems: inventory

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [Design details - Average cost](https://learn.microsoft.com/dynamics365/business-central/design-details-average-cost) — possibly related: Documents average cost calculation and cost adjustment mechanism in inventory. (model-linked)

Source: metadata of a merged pull request in microsoft/BCApps (bcapps): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
