---
id: change/bcapps/13112
type: change
title: "#13112  [Main][ALL-E] Canceling a posted purchase invoice fails or misallocates item charges assigned to posted document types other than Purchase ReceiptsInitial commit"
summary: Fixed a bug where canceling a posted purchase invoice could fail or misallocate item charges when those charges were assigned to documents other than Purchase Receipts. The fix ensures all supported document types are handled and correct cost amounts are used.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit copy document mgt.
  - codeunit item charge assgnt. (purch.)
  - codeunit item charge assgnt. (sales)
system: platform
review:
  state: reviewed
  by: opus
  at: "2026-11-26T01:03:41.144Z"
  flags: []
generated:
  at: "2026-11-30T13:33:07.232Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 5dbd1580edea704fd88b8dd083b57bf3ec2e226d
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13112
    title: "microsoft/BCApps#13112:  [Main][ALL-E] Canceling a posted purchase invoice fails or misallocates item charges assigned to posted document types other than Purchase ReceiptsInitial commit"
    date: "2026-11-25"
    commit: 5dbd1580edea704fd88b8dd083b57bf3ec2e226d
    t: null
    quote: Canceling a posted purchase invoice fails or misallocates item charges assigned to posted document types other than Purchase Receipts
links:
  learn: []
  objects:
    - object/codeunit/6620
    - object/codeunit/5805
    - object/codeunit/5807
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-creating-and-interacting-with-odatav4-bound-action
      title: Creating and Interacting with an OData V4 Bound Action
      label: possibly related
      why: touches Codeunit 6620 "Copy Document Mgt."
      by: code
    - to: https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-extending-item-charges
      title: Extending Item Charges Distribution Methods
      label: possibly related
      why: touches Codeunit 5805 "Item Charge Assgnt. (Purch.)"
      by: code
    - to: https://learn.microsoft.com/dynamics365/business-central/sales-how-correct-cancel-sales-invoice
      title: Correct or cancel a posted sales invoice
      label: possibly related
      why: Documents canceling posted invoices and automatic creation of corrective credit memos for purchases.
      by: model
    - to: https://learn.microsoft.com/dynamics365/business-central/reports/report-5806
      title: Item Charges - Specification (report)
      label: possibly related
      why: Item Charges - Specification report shows posted item charges, relevant to item charge allocation issues.
      by: model
number: 13112
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13112
kind: pr
base_branch: main
major: "30"
merged_at: "2026-11-25T08:20:51Z"
author: sanjmaurya
author_type: User
community_contribution: false
labels:
  - "Ownership: Needs Review"
  - "Team: Other"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 10
  additions: 982
  deletions: 124
  al: 8
apps:
  - Base Application
objects_touched:
  - key: codeunit/6620
    page: codeunit/6620
    type: codeunit
    id: 6620
    name: Copy Document Mgt.
    app: Base Application
    status: modified
  - key: codeunit/5805
    page: codeunit/5805
    type: codeunit
    id: 5805
    name: Item Charge Assgnt. (Purch.)
    app: Base Application
    status: modified
  - key: codeunit/5807
    page: codeunit/5807
    type: codeunit
    id: 5807
    name: Item Charge Assgnt. (Sales)
    app: Base Application
    status: modified
objects_unjoined:
  - path: src/Layers/IT/BaseApp/Utilities/CopyDocumentMgt.Codeunit.al
    status: modified
    reason: not-in-snapshot
  - path: src/Layers/NL/BaseApp/Utilities/CopyDocumentMgt.Codeunit.al
    status: modified
    reason: not-in-snapshot
  - path: src/Layers/RU/BaseApp/Utilities/CopyDocumentMgt.Codeunit.al
    status: modified
    reason: not-in-snapshot
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 653898
systems:
  - platform
  - purchasing
  - sales
quote: Canceling a posted purchase invoice fails or misallocates item charges assigned to posted document types other than Purchase Receipts
joined_against:
  major: "30"
  commit: f53bb0f1ecd89fde9f133f9dcaf5bf43cf5f2671
---

# #13112  [Main][ALL-E] Canceling a posted purchase invoice fails or misallocates item charges assigned to posted document types other than Purchase ReceiptsInitial commit

> Fixed a bug where canceling a posted purchase invoice could fail or misallocate item charges when those charges were assigned to documents other than Purchase Receipts. The fix ensures all supported document types are handled and correct cost amounts are used.

[Pull request](https://github.com/microsoft/BCApps/pull/13112) · merged into `main` (BC30) on 2026-11-25 by sanjmaurya · 10 files (+982 -124), 8 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Item charge assignments are now recreated for all supported targets (Purchase Receipt, Transfer Receipt, Purchase Return Shipment, Sales Shipment, Sales Return Receipt) during corrective document creation
- Correct cost amount types are applied based on document type: Cost Amount (Non-Invtbl.) for Purchase Return Shipment and Sales Shipment; Cost Amount (Actual) for others
- Rounding adjustments now only affect supported value entries, preventing quantities from shifting to incorrect assignments
- Changes applied across all localization layers (W1, ES, IT, NA, NL, RU)
- Behaviour changes for users or extensions.

## AL objects touched

- [Codeunit 6620 "Copy Document Mgt."](../../objects/codeunit/6620.md), Base Application: modified
- [Codeunit 5805 "Item Charge Assgnt. (Purch.)"](../../objects/codeunit/5805.md), Base Application: modified
- [Codeunit 5807 "Item Charge Assgnt. (Sales)"](../../objects/codeunit/5807.md), Base Application: modified
- `src/Layers/IT/BaseApp/Utilities/CopyDocumentMgt.Codeunit.al`: modified, not in the BC30 snapshot
- `src/Layers/NL/BaseApp/Utilities/CopyDocumentMgt.Codeunit.al`: modified, not in the BC30 snapshot
- `src/Layers/RU/BaseApp/Utilities/CopyDocumentMgt.Codeunit.al`: modified, not in the BC30 snapshot

## Context

- Work items: AB#653898
- Labels: Ownership: Needs Review, Team: Other
- Systems: platform, purchasing, sales
- From the description: "Canceling a posted purchase invoice fails or misallocates item charges assigned to posted document types other than Purchase Receipts"

## Possibly related

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

- [Creating and Interacting with an OData V4 Bound Action](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-creating-and-interacting-with-odatav4-bound-action) — possibly related: touches Codeunit 6620 "Copy Document Mgt."
- [Extending Item Charges Distribution Methods](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-extending-item-charges) — possibly related: touches Codeunit 5805 "Item Charge Assgnt. (Purch.)"
- [Correct or cancel a posted sales invoice](https://learn.microsoft.com/dynamics365/business-central/sales-how-correct-cancel-sales-invoice) — possibly related: Documents canceling posted invoices and automatic creation of corrective credit memos for purchases. (model-linked)
- [Item Charges - Specification (report)](https://learn.microsoft.com/dynamics365/business-central/reports/report-5806) — possibly related: Item Charges - Specification report shows posted item charges, relevant to item charge allocation issues. (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).
