---
id: change/bcapps/13220
type: change
title: "#13220 Fix average cost adjustment overflow on same-period transfers"
summary: Same-period transfers no longer cause average cost adjustments to overflow when item quantities are zero or negative. The fix skips transfer recalculation when cumulative item ledger quantities are nonpositive, preserving transfer costs and normal forwarding.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit inventory adjustment
system: inventory
review:
  state: reviewed
  by: opus
  at: "2026-10-30T01:09:54.080Z"
  flags: []
generated:
  at: "2026-11-04T00:16:32.194Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 6eb637bcd5e5ab9d157460bbfd9a11914ab30273
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13220
    title: "microsoft/BCApps#13220: Fix average cost adjustment overflow on same-period transfers"
    date: "2026-10-28"
    commit: 6eb637bcd5e5ab9d157460bbfd9a11914ab30273
    t: null
    quote: Prevent same-period transfers from repeatedly amplifying costs until average-cost adjustment overflows when the item's cumulative quantity is zero or negative.
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: Explains average cost calculation methodology and adjustments through the Adjust Cost batch job.
      by: model
    - to: https://learn.microsoft.com/dynamics365/business-central/design-details-cost-adjustment
      title: Design details - Cost adjustment
      label: possibly related
      why: Documents cost adjustment mechanism and processing of cost adjustments from sources to recipients.
      by: model
number: 13220
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13220
kind: pr
base_branch: main
major: "30"
merged_at: "2026-10-28T09:54:08Z"
author: alexei-dobriansky
author_type: User
community_contribution: false
labels:
  - "Ownership: Manual"
  - "Team: SCM"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 4
  additions: 287
  deletions: 25
  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: 13423
    base: releases/29.x
    url: https://github.com/microsoft/BCApps/pull/13423
fixes_issues: []
work_items:
  - 656611
systems:
  - inventory
quote: Prevent same-period transfers from repeatedly amplifying costs until average-cost adjustment overflows when the item's cumulative quantity is zero or negative.
joined_against:
  major: "30"
  commit: d2abc1d2ceae394331716c8183ef60e1534c2ce0
---

# #13220 Fix average cost adjustment overflow on same-period transfers

> Same-period transfers no longer cause average cost adjustments to overflow when item quantities are zero or negative. The fix skips transfer recalculation when cumulative item ledger quantities are nonpositive, preserving transfer costs and normal forwarding.

[Pull request](https://github.com/microsoft/BCApps/pull/13220) · merged into `main` (BC30) on 2026-10-28 by alexei-dobriansky · 4 files (+287 -25), 3 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Prevents cost amplification from repeated transfer repricings when cumulative item quantity is zero or negative
- Skips transfer average-cost recalculation in Item-wide average costing when pre-exclusion quantity is nonpositive
- Reuses existing quantity summation through local parameters to avoid additional queries
- Includes regression tests for negative-balance, zero-balance, and positive-balance transfer scenarios
- Applied to W1, APAC, and RU layers
- Behaviour changes for users or extensions.

## 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

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

## Context

- Work items: AB#656611
- Labels: Ownership: Manual, Team: SCM
- Systems: inventory
- From the description: "Prevent same-period transfers from repeatedly amplifying costs until average-cost adjustment overflows when the item's cumulative quantity is zero or negative."

## 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: Explains average cost calculation methodology and adjustments through the Adjust Cost batch job. (model-linked)
- [Design details - Cost adjustment](https://learn.microsoft.com/dynamics365/business-central/design-details-cost-adjustment) — possibly related: Documents cost adjustment mechanism and processing of cost adjustments from sources to recipients. (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).
