Repository navigation
A declared unit with a plural magnitude is read in that magnitude, so "$5 billion" under "USD millions" is 5000 - #1434
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
… "$5 billion" under "USD millions" is 5000 Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
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.
Why
attribute_valueconverts a number into the attribute's declared unit. It finds the magnitude in the unit withmagnitude, which knowsmillion,thousandand so on in the singular only. Financial tables almost always label the column in the plural: "USD millions", "$ thousands", "thousands of dollars". With such a unit the magnitude is not found, the exponent falls back to 0, and the absolute value is stored as if it were already in millions:"$5 billion"under "USD millions" is stored as 5000000000 instead of 5000."$2.5 million"under "$ thousands" is stored as 2500000 instead of 2500."USD million" (merged in #1417) and "million dollars" already work, so the same figure lands a million times too large only because the label has an
s.What changes
When reading the declared unit, a magnitude word may end in a plural
s(millions,thousands,billions). That applies to both places the unit is read: the leading word ("thousands of dollars") and the trailing word ("USD millions"). The quantity parser for the value itself is unchanged, and the currency mismatch check still applies ("€30 million" under "USD millions" is still no value).How it was checked
a_unit_with_a_plural_magnitude_is_read_in_that_magnitude, covers "USD millions", "$ thousands", "thousands of dollars", "Millions", and the currency mismatch.left: Some(Number(5000000000.0)) right: Some(Number(5000.0)).cargo test -p utopia-extract --lib: 113 passed.cargo fmt -p utopia-extract --checkandcargo clippy -p utopia-extract --all-targets -- -D warningspass.Before review
git commit -s)cargo fmt --all --check,cargo clippyandcargo testpass for the touched crate