---
id: change/bcapps/13547
type: change
title: "#13547 [29.X]-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: The correct posted sales invoice functionality now properly handles return orders linked to posted sales invoices through applies-to document numbers on credit memos, fixing incorrect line quantity updates.
tier: official
language: en
tags:
  - fix
  - releases/29.x
  - bc29
  - codeunit correct posted sales invoice
system: sales
review:
  state: reviewed
  by: opus
  at: "2026-11-04T00:58:50.679Z"
  flags: []
generated:
  at: "2026-11-25T00:13:20.045Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 2ebeefd8406e307d26bc7fc35c873bcadc635a65
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13547
    title: "microsoft/BCApps#13547: [29.X]-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-03"
    commit: 2ebeefd8406e307d26bc7fc35c873bcadc635a65
    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 or canceling posted sales invoices and the related reversals and credit memo creation.
      by: model
number: 13547
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13547
kind: pr
base_branch: releases/29.x
major: "29"
merged_at: "2026-11-03T09:57:37Z"
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:
  - 657706
systems:
  - sales
quote: null
joined_against:
  major: "29"
  commit: e646fc169eb3bb7b1947b2089ed943d91dec46b0
---

# #13547 [29.X]-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

> The correct posted sales invoice functionality now properly handles return orders linked to posted sales invoices through applies-to document numbers on credit memos, fixing incorrect line quantity updates.

[Pull request](https://github.com/microsoft/BCApps/pull/13547) · merged into `releases/29.x` (BC29) on 2026-11-03 by neeleshsinghal · 5 files (+202 -0), 3 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Corrects quantity update logic when return orders reference posted sales invoices via applies-to field
- Addresses issue where sales order line quantities were incorrectly modified after posting
- Includes test coverage for the copy purchase and sales documents functionality
- Changes applied across multiple localization layers (W1, ES, APAC)
- 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 BC29 snapshot

## Context

- Work items: AB#657706
- 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 or canceling posted sales invoices and the related reversals and credit memo creation. (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).
