Repository navigation
Fix AnyMoney currency checks and extend AnyMoney, JSON and SQL support - #14
Merged
Merged
Conversation
- As, Add, Sub and Cmp of AnyMoney compare the minor units and the code. Before, a currency with the same code and other minor units changed the value without an error, for example 1.0000 USD became USD 100.00. - Add Mul, Div, MulFactor, RoundCash, Abs, Neg, Allocate, Sign, IsPositive and IsNegative to AnyMoney. - Add AnyMoney.ScanColumns to read an amount column and a currency code column with database/sql. - UnmarshalJSON of Money and AnyMoney does not change the value for a JSON null. The currency code of Money JSON is not case-sensitive. - Scan accepts a float64 with at most 15 significant digits, as SQLite returns for a NUMERIC column. - Replace Validate and ErrValidation with InRange, which returns a bool. - Allocate accepts zero ratios if one ratio is positive. ErrNegativeOrZeroRatios is now ErrInvalidRatios. - Document the int64 limit of the terms of Rate and Factor. Signed-off-by: ayn <ayn.khatib@gmail.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.
Fix: AnyMoney As/Add/Sub/Cmp compare minor units too, so a same-code currency with other minor units no longer changes the value.
Add AnyMoney Mul/Div/MulFactor/RoundCash/Abs/Neg/Allocate/Sign and ScanColumns; JSON null is a no-op; Money JSON code is case-insensitive; Scan accepts exact float64 (SQLite).
Breaking (beta): Validate/ErrValidation become InRange; Allocate accepts zero ratios and ErrNegativeOrZeroRatios becomes ErrInvalidRatios.