---
id: change/bcapps/10083
type: change
title: "#10083 [main]- Negative Shipped and Invoiced Quantities appear on Sales Order Lines after using the Copy Document from a Sales Credit Memo."
summary: When a sales credit memo created with Copy Document from a posted invoice that has the same item on several lines is posted, each credit memo line now resolves to a different invoice line. This stops negative Quantity Shipped and Quantity Invoiced on one sales order line while another order line stays unchanged.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit correct posted sales invoice
  - table sales cr.memo line
system: sales
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:09:43.515Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 6c1bfdb9c4bfc05b4186325e7e37cc155ab18b37
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/10083
    title: "microsoft/BCApps#10083: [main]- Negative Shipped and Invoiced Quantities appear on Sales Order Lines after using the Copy Document from a Sales Credit Memo."
    date: "2026-08-11"
    commit: 6c1bfdb9c4bfc05b4186325e7e37cc155ab18b37
    t: null
    quote: Copy Document does not populate Appl.-from Item Entry on the credit memo lines
links:
  learn: []
  objects:
    - object/codeunit/1303
    - object/table/115
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 10083
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/10083
kind: pr
base_branch: main
major: "30"
merged_at: "2026-08-11T13:34:49Z"
author: MSNehaNawal
author_type: User
community_contribution: false
labels:
  - "Team: SCM"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 15
  additions: 390
  deletions: 28
  al: 14
apps:
  - Base Application
objects_touched:
  - key: codeunit/1303
    page: codeunit/1303
    type: codeunit
    id: 1303
    name: Correct Posted Sales Invoice
    app: Base Application
    status: modified
  - key: table/115
    page: table/115
    type: table
    id: 115
    name: Sales Cr.Memo Line
    app: Base Application
    status: modified
objects_unjoined:
  - path: src/Layers/ES/BaseApp/Sales/History/CorrectPostedSalesInvoice.Codeunit.al
    status: modified
    reason: not-in-snapshot
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 646375
systems:
  - sales
quote: Copy Document does not populate Appl.-from Item Entry on the credit memo lines
joined_against:
  major: "30"
  commit: f18567dc08e2bd162bf192e1da4d714b57eb099f
---

# #10083 [main]- Negative Shipped and Invoiced Quantities appear on Sales Order Lines after using the Copy Document from a Sales Credit Memo.

> When a sales credit memo created with Copy Document from a posted invoice that has the same item on several lines is posted, each credit memo line now resolves to a different invoice line. This stops negative Quantity Shipped and Quantity Invoiced on one sales order line while another order line stays unchanged.

[Pull request](https://github.com/microsoft/BCApps/pull/10083) · merged into `main` (BC30) on 2026-08-11 by MSNehaNawal · 15 files (+390 -28), 14 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Added an overload to GetSalesInvoiceLine that tracks already-consumed invoice lines to avoid duplicate matching
- Introduced FindUnusedSalesInvoiceLine helper method to skip previously matched invoice lines
- UpdateSalesOrderLineIfExist maintains a temporary buffer of resolved invoice lines to prevent reuse across multiple credit memo lines
- Fixes issue where all credit memo lines matched the first invoice line when copying from invoices with duplicate items
- Behaviour changes for users or extensions.

## AL objects touched

- [Codeunit 1303 "Correct Posted Sales Invoice"](../../objects/codeunit/1303.md), Base Application: modified
- [Table 115 "Sales Cr.Memo Line"](../../objects/table/115.md), Base Application: modified
- `src/Layers/ES/BaseApp/Sales/History/CorrectPostedSalesInvoice.Codeunit.al`: modified, not in the BC30 snapshot

## Context

- Work items: AB#646375
- Labels: Team: SCM
- Systems: sales
- From the description: "Copy Document does not populate Appl.-from Item Entry on the credit memo lines"

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).
