---
id: change/bcapps/10462
type: change
title: "#10462 [Shopify] Fix order edit retaining discount allocation for removed quantity"
summary: The Shopify connector now correctly adjusts line-level discount amounts when refunds reduce order line quantities, preventing over-discounting of the remaining quantity in sales documents.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit shpfy import order
system: integration
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:07:46.868Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 5eee885d151c5108935dfb1ee49ed106da448344
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/10462
    title: "microsoft/BCApps#10462: [Shopify] Fix order edit retaining discount allocation for removed quantity"
    date: "2026-08-24"
    commit: 5eee885d151c5108935dfb1ee49ed106da448344
    t: null
    quote: null
links:
  learn: []
  objects:
    - object/codeunit/30161
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 10462
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/10462
kind: pr
base_branch: main
major: "30"
merged_at: "2026-08-24T15:55:02Z"
author: onbuyuka
author_type: User
community_contribution: false
labels:
  - "AL: Apps (W1)"
  - "Team: Integrations"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 3
  additions: 172
  deletions: 0
  al: 1
apps:
  - Shopify
objects_touched:
  - key: codeunit/30161
    page: codeunit/30161
    type: codeunit
    id: 30161
    name: Shpfy Import Order
    app: Shopify
    status: modified
objects_unjoined: []
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 647146
systems:
  - integration
quote: null
joined_against:
  major: "30"
  commit: ecbc028c25dbe83b61313bc566e6c1d41184bb1c
---

# #10462 [Shopify] Fix order edit retaining discount allocation for removed quantity

> The Shopify connector now correctly adjusts line-level discount amounts when refunds reduce order line quantities, preventing over-discounting of the remaining quantity in sales documents.

[Pull request](https://github.com/microsoft/BCApps/pull/10462) · merged into `main` (BC30) on 2026-08-24 by onbuyuka · 3 files (+172 -0), 1 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Fixed discount allocation calculation in refund processing to account for removed quantities
- Discount amount is now reduced proportionally with quantity reduction using unit price and subtotal derivation
- Added unit tests to verify discount reduction and quantity adjustment for discounted order lines
- Ensures line discount reconciles with order header discount after quantity refunds
- Only affects Shopify refund/return import when enabled
- Behaviour changes for users or extensions.

## AL objects touched

- [Codeunit 30161 "Shpfy Import Order"](../../objects/codeunit/30161.md), Shopify: modified

## Context

- Work items: AB#647146
- Labels: AL: Apps (W1), Team: Integrations
- Systems: integration

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