---
id: change/bcapps/9697
type: change
title: "#9697 Features/494919 master mx cfdi rounding e invoice docs"
summary: Mexican CFDI stamp requests now recalculate SubTotal as the sum of line amounts rounded to 6 decimals, excluding retention lines, and recompute Total to match. Before calling the PAC, rounding models are checked locally against per-line tax amounts. Other models are tried only if the PAC rejects the document with a rounding error.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit e-invoice mgt.
system: integration
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:10:12.573Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 71cdfb415cf79d6004af2e1507a3f7aa8db1fda5
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/9697
    title: "microsoft/BCApps#9697: Features/494919 master mx cfdi rounding e invoice docs"
    date: "2026-08-05"
    commit: 71cdfb415cf79d6004af2e1507a3f7aa8db1fda5
    t: null
    quote: The generated CFDI XML produced rounding mismatches in SubTotal and per-line tax amounts, causing PAC validation errors.
links:
  learn: []
  objects:
    - object/codeunit/10145-ca
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 9697
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/9697
kind: pr
base_branch: main
major: "30"
merged_at: "2026-08-05T14:03:17Z"
author: v-mjofre
author_type: User
community_contribution: false
labels:
  - "Team: Integrations"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 3
  additions: 561
  deletions: 59
  al: 1
apps:
  - Base Application
objects_touched:
  - key: codeunit/10145
    page: codeunit/10145-ca
    type: codeunit
    id: 10145
    name: E-Invoice Mgt.
    app: Base Application
    status: modified
objects_unjoined: []
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 638201
systems:
  - integration
quote: The generated CFDI XML produced rounding mismatches in SubTotal and per-line tax amounts, causing PAC validation errors.
joined_against:
  major: "30"
  commit: ecbc028c25dbe83b61313bc566e6c1d41184bb1c
---

# #9697 Features/494919 master mx cfdi rounding e invoice docs

> Mexican CFDI stamp requests now recalculate SubTotal as the sum of line amounts rounded to 6 decimals, excluding retention lines, and recompute Total to match. Before calling the PAC, rounding models are checked locally against per-line tax amounts. Other models are tried only if the PAC rejects the document with a rounding error.

[Pull request](https://github.com/microsoft/BCApps/pull/9697) · merged into `main` (BC30) on 2026-08-05 by v-mjofre · 3 files (+561 -59), 1 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- SubTotal is recalculated as the sum of individually rounded line amounts to comply with CFDI40108 requirements
- Total is recomputed after SubTotal adjustment to maintain consistency with CFDI40119 standards
- A new local rounding model pre-validation process identifies the correct rounding approach before sending documents to the PAC
- Fallback mechanism now intelligently selects alternative rounding models only when PAC rejects with rounding-specific errors
- Retention lines are properly excluded from SubTotal calculations and comprehensive tests prevent future regressions
- Behaviour changes for users or extensions.

## AL objects touched

- [Codeunit 10145 "E-Invoice Mgt."](../../objects/codeunit/10145-ca.md), Base Application (CA layer): modified

## Context

- Work items: AB#638201
- Labels: Team: Integrations
- Systems: integration
- From the description: "The generated CFDI XML produced rounding mismatches in SubTotal and per-line tax amounts, causing PAC validation errors."

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