Skip to content

[28.2] Fix MLLM decimal parsing for locale-formatted invoices#8832

Open
Groenbech96 wants to merge 1 commit into
releases/28.2from
magnushar/backport-mllm-decimal-28_2
Open

[28.2] Fix MLLM decimal parsing for locale-formatted invoices#8832
Groenbech96 wants to merge 1 commit into
releases/28.2from
magnushar/backport-mllm-decimal-28_2

Conversation

@Groenbech96

@Groenbech96 Groenbech96 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Backport of #8310 to releases/28.2.

Cherry-picks commit bbad0a8.

Summary

  • Root cause: The UBL schema template used string "0" placeholders for numeric fields, causing the MLLM to return locale-formatted strings (e.g. Swedish "2,34") instead of JSON numbers. AL's AsDecimal() then stripped the comma, turning "2,34" into 234.
  • Fix 1 (ubl_example.json): Changed all numeric string "0" placeholders to 0 (JSON numbers).
  • Fix 2 (EDocMLLMExtraction-SystemPrompt.md): Added explicit rule requiring XML decimal format.
  • Fix 3 (EDocMLLMSchemaHelper.Codeunit.al): Replaced AsDecimal() with Evaluate(…, AsText(), 9) in GetDecimal() for locale-independent parsing.

Fixes AB#640595

## Summary

- **Root cause**: The UBL schema template used string `"0"` placeholders
for numeric fields, causing the MLLM to return locale-formatted strings
(e.g. Swedish `"2,34"`) instead of JSON numbers. AL's `AsDecimal()` then
stripped the comma, turning `"2,34"` into `234`.
- **Fix 1** (`ubl_example.json`): Changed all numeric string `"0"`
placeholders to `0` (JSON numbers), teaching the model to return proper
numeric values.
- **Fix 2** (`EDocMLLMExtraction-SystemPrompt.md`): Added explicit rule
requiring XML decimal format (period as decimal separator, no thousands
separators).
- **Fix 3** (`EDocMLLMSchemaHelper.Codeunit.al`): Replaced `AsDecimal()`
with `Evaluate(…, AsText(), 9)` in `GetDecimal()`, which parses
XML-format decimals locale-independently — consistent with how
`GetDate()` already handles date strings.

[AB#640342](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/640342)

---------

Co-authored-by: Magnus Hartvig Grønbech <magnushar@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit bbad0a8)
@Groenbech96 Groenbech96 requested review from a team June 26, 2026 07:23
@Groenbech96 Groenbech96 requested a review from a team as a code owner June 26, 2026 07:23
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jun 26, 2026
@github-actions github-actions Bot added this to the Version 28.2 milestone Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants