---
id: change/bcapps/13627
type: change
title: "#13627 [E-Documents] Fix division by zero importing zero-amount purchase order lines"
summary: E-Document import now correctly handles zero-amount purchase order lines by preventing division-by-zero errors when calculating discount percentages.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - table e-doc. imported line
system: integration
review:
  state: reviewed
  by: opus
  at: "2026-11-15T00:48:09.860Z"
  flags: []
generated:
  at: "2026-11-30T00:15:18.424Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 3a726cbf9fe1272de61c64bb97ced1bf97625966
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13627
    title: "microsoft/BCApps#13627: [E-Documents] Fix division by zero importing zero-amount purchase order lines"
    date: "2026-11-13"
    commit: 3a726cbf9fe1272de61c64bb97ced1bf97625966
    t: null
    quote: Guard the denominator and explicitly set the imported discount percentage to zero when it is zero.
links:
  learn: []
  objects:
    - object/table/6165
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/check-purchase-amounts
      title: Check amounts on purchase invoices and credit memos
      label: possibly related
      why: Documents amount validation on purchase invoice lines where division by zero error occurs.
      by: model
number: 13627
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13627
kind: pr
base_branch: main
major: "30"
merged_at: "2026-11-13T11:04:36Z"
author: gggdttt
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: 2
  additions: 79
  deletions: 1
  al: 1
apps:
  - EDocument
objects_touched:
  - key: table/6165
    page: table/6165
    type: table
    id: 6165
    name: E-Doc. Imported Line
    app: EDocument
    status: modified
objects_unjoined: []
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 654114
systems:
  - integration
quote: Guard the denominator and explicitly set the imported discount percentage to zero when it is zero.
joined_against:
  major: "30"
  commit: d2abc1d2ceae394331716c8183ef60e1534c2ce0
---

# #13627 [E-Documents] Fix division by zero importing zero-amount purchase order lines

> E-Document import now correctly handles zero-amount purchase order lines by preventing division-by-zero errors when calculating discount percentages.

[Pull request](https://github.com/microsoft/BCApps/pull/13627) · merged into `main` (BC30) on 2026-11-13 by gggdttt · 2 files (+79 -1), 1 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Guard denominator in discount percentage calculation to prevent division by zero on zero-amount lines
- Set imported discount percentage to zero when denominator is zero while preserving existing calculation for nonzero cases
- Added six regression tests covering nine input combinations including zero/nonzero amounts and discounts
- No schema, API, permission, or upgrade changes required
- Preserves behavior for all nonzero-denominator scenarios including negative amounts
- Behaviour changes for users or extensions.

## AL objects touched

- [Table 6165 "E-Doc. Imported Line"](../../objects/table/6165.md), EDocument: modified

## Context

- Work items: AB#654114
- Labels: AL: Apps (W1), Team: Integrations
- Systems: integration
- From the description: "Guard the denominator and explicitly set the imported discount percentage to zero when it is zero."

## Possibly related

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

- [Check amounts on purchase invoices and credit memos](https://learn.microsoft.com/dynamics365/business-central/check-purchase-amounts) — possibly related: Documents amount validation on purchase invoice lines where division by zero error occurs. (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).
