Skip to content

fix(db): export numbers at DDL scale instead of a fixed two decimals - #28

Merged
karlkauc merged 1 commit into
mainfrom
fix/db-export-decimal-precision
Aug 30, 2026
Merged

fix(db): export numbers at DDL scale instead of a fixed two decimals#28
karlkauc merged 1 commit into
mainfrom
fix/db-export-decimal-precision

Conversation

@karlkauc

Copy link
Copy Markdown
Contributor

Summary

Open item from the review: all four DB exporters rendered every number with %.2f (SharesOutstanding with %.0f) although schema.sql allows DECIMAL(9,4) for TotalPercentage and DECIMAL(28,6) for quantities / NavPrice / SharesOutstanding. Inputs with more decimals were silently truncated on export.

  • One helper per language (_num / num / Num): render at the DDL scale, strip trailing zeros down to a floor of two decimals (zero for SharesOutstanding). Amounts stay at scale 2.
  • Database_Integration/README.md documents the rule.

Verification (local)

Multi-Fund copy with TotalPercentage 32.0034, Units 50000.123456, NavPrice 100.001234:

language import → export xml_equiv XSD
Python 0 EQUIVALENT validates
Java 0 EQUIVALENT validates
JavaScript 0 EQUIVALENT validates
C# 0 EQUIVALENT validates

All four render byte-identical values (32.0034 / 50000.123456 / 100.001234 / 150000). Before the fix Python reported DIFFER … '32.0034' != '32.00'. Committed fixture and Mixed-Fund sample round-trip unchanged (CI's DB step covers them).

🤖 Generated with Claude Code

https://claude.ai/code/session_01YXZWhwE5EbHSybt55K6oUZ

All four exporters formatted every number with "%.2f" (and SharesOutstanding
with "%.0f") although schema.sql declares TotalPercentage DECIMAL(9,4) and
quantities / NavPrice / SharesOutstanding DECIMAL(28,6). Any input with more
than two decimals was silently truncated on export; xml_equiv.py (numeric
comparison) reported it, e.g. TotalPercentage 32.0034 -> 32.00.

Add one formatting helper per language (num/_num/Num: render at the DDL
scale, strip trailing zeros down to a floor of two decimals, zero for
SharesOutstanding) and route percentage / quantity / NavPrice /
SharesOutstanding through it; amounts keep scale 2. README documents the
rule.

Verified with a Multi-Fund copy carrying 32.0034 %, 50000.123456 units and
NavPrice 100.001234: import -> export in Python, Java, JavaScript and C# is
EQUIVALENT and XSD-valid, and all four render byte-identical values
(32.0034 / 50000.123456 / 100.001234 / 150000). The committed fixture and
the Mixed-Fund sample round-trip unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YXZWhwE5EbHSybt55K6oUZ
@karlkauc
karlkauc merged commit 7eac032 into main Aug 30, 2026
4 checks passed
@karlkauc
karlkauc deleted the fix/db-export-decimal-precision branch August 30, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant