---
id: change/bcapps/13417
type: change
title: "#13417 [Master]-Sales Order line quantities are incorrectly updated after posting a Return Order linked to a Posted Sales Invoice via Applies-to Doc. No. on a Credit Memo."
summary: Posting a return order that is linked to a posted sales invoice through Applies-to Doc. No. on a credit memo no longer updates the original sales order line quantities incorrectly. The fix is in Correct Posted Sales Invoice for the W1, APAC and ES layers, with new tests.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit correct posted sales invoice
system: sales
review:
  state: reviewed
  by: opus
  at: "2026-11-03T00:58:53.877Z"
  flags: []
generated:
  at: "2026-11-05T00:14:20.359Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 6419857e939843e2e00da8e51f9d0b5729f3107b
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13417
    title: "microsoft/BCApps#13417: [Master]-Sales Order line quantities are incorrectly updated after posting a Return Order linked to a Posted Sales Invoice via Applies-to Doc. No. on a Credit Memo."
    date: "2026-11-02"
    commit: 6419857e939843e2e00da8e51f9d0b5729f3107b
    t: null
    quote: null
links:
  learn: []
  objects:
    - object/codeunit/1303
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
  related:
    - 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 correcting posted sales invoices via credit memos and return order linking
      by: model
number: 13417
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13417
kind: pr
base_branch: main
major: "30"
merged_at: "2026-11-02T11:50:05Z"
author: neeleshsinghal
author_type: User
community_contribution: false
labels:
  - "Team: SCM"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 5
  additions: 202
  deletions: 0
  al: 3
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
objects_unjoined:
  - path: src/Layers/ES/BaseApp/Sales/History/CorrectPostedSalesInvoice.Codeunit.al
    status: modified
    reason: not-in-snapshot
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 657201
systems:
  - sales
quote: null
joined_against:
  major: "30"
  commit: d2abc1d2ceae394331716c8183ef60e1534c2ce0
---

# #13417 [Master]-Sales Order line quantities are incorrectly updated after posting a Return Order linked to a Posted Sales Invoice via Applies-to Doc. No. on a Credit Memo.

> Posting a return order that is linked to a posted sales invoice through Applies-to Doc. No. on a credit memo no longer updates the original sales order line quantities incorrectly. The fix is in Correct Posted Sales Invoice for the W1, APAC and ES layers, with new tests.

[Pull request](https://github.com/microsoft/BCApps/pull/13417) · merged into `main` (BC30) on 2026-11-02 by neeleshsinghal · 5 files (+202 -0), 3 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Fixes issue where return order posting incorrectly adjusted sales order line quantities
- Involves credit memo applies-to document links to posted invoices
- Changes made to correct posted sales invoice codeunit across regions
- Added test coverage for the purchase/sales copy document scenario
- Behaviour changes for users or extensions.

## AL objects touched

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

## Context

- Work items: AB#657201
- Labels: Team: SCM
- Systems: sales

## Possibly related

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

- [Correct or cancel a posted sales invoice](https://learn.microsoft.com/dynamics365/business-central/sales-how-correct-cancel-sales-invoice) — possibly related: Documents correcting posted sales invoices via credit memos and return order linking (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).
