fix(db): export numbers at DDL scale instead of a fixed two decimals - #28
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Open item from the review: all four DB exporters rendered every number with
%.2f(SharesOutstandingwith%.0f) althoughschema.sqlallowsDECIMAL(9,4)forTotalPercentageandDECIMAL(28,6)for quantities /NavPrice/SharesOutstanding. Inputs with more decimals were silently truncated on export._num/num/Num): render at the DDL scale, strip trailing zeros down to a floor of two decimals (zero forSharesOutstanding). Amounts stay at scale 2.Database_Integration/README.mddocuments the rule.Verification (local)
Multi-Fund copy with
TotalPercentage 32.0034,Units 50000.123456,NavPrice 100.001234:xml_equivAll four render byte-identical values (
32.0034/50000.123456/100.001234/150000). Before the fix Python reportedDIFFER … '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