fix-amount-conversion #87

Merged
Alfred-mk merged 9 commits from fix-amount-conversion into master 2025-06-26 14:07:29 +02:00
Member
  • Fix amount conversions to prevent input such as 0.1 ending up as 0.09
  • Updates the ParseAndScaleAmount to return the correct amount in the voucher transfers and swaps
- Fix amount conversions to prevent input such as 0.1 ending up as 0.09 - Updates the ParseAndScaleAmount to return the correct amount in the voucher transfers and swaps
Alfred-mk added 4 commits 2025-06-24 14:12:48 +02:00
Alfred-mk requested review from kamikazechaser 2025-06-24 14:13:02 +02:00

Add tests of 18 d.p. to TestParseAndScaleAmount and for the menu handler itself.

Generally the following should be the behaviour:

1.85 inputted for a 18d.p token - > 1850000000000000000
1.8599999999 inputted for a 18 d.p. token -> 1850000000000000000 (we truncate anything after 2 d.p.)
2.32 inputted for a 6 d.p token -> 2320000

Add tests of 18 d.p. to TestParseAndScaleAmount and for the menu handler itself. Generally the following should be the behaviour: 1.85 inputted for a 18d.p token - > 1850000000000000000 1.8599999999 inputted for a 18 d.p. token -> 1850000000000000000 (we truncate anything after 2 d.p.) 2.32 inputted for a 6 d.p token -> 2320000
Alfred-mk added 1 commit 2025-06-26 11:19:23 +02:00
Alfred-mk added 4 commits 2025-06-26 11:30:51 +02:00
Author
Member

Add tests of 18 d.p. to TestParseAndScaleAmount and for the menu handler itself.

Generally the following should be the behaviour:

1.85 inputted for a 18d.p token - > 1850000000000000000
1.8599999999 inputted for a 18 d.p. token -> 1850000000000000000 (we truncate anything after 2 d.p.)
2.32 inputted for a 6 d.p token -> 2320000

This has been fixed.

  1. TruncateDecimalString has been added as a helper function to truncate the amounts to whichever specified d.p. This has been set to 2 in the menuhanlder
  2. The ParseAndScaleAmount func will be called after the amount has been truncated to the specified d.p.
  3. Tests have been added to show the behavior of different cases.
> Add tests of 18 d.p. to TestParseAndScaleAmount and for the menu handler itself. > > Generally the following should be the behaviour: > > 1.85 inputted for a 18d.p token - > 1850000000000000000 > 1.8599999999 inputted for a 18 d.p. token -> 1850000000000000000 (we truncate anything after 2 d.p.) > 2.32 inputted for a 6 d.p token -> 2320000 > > This has been fixed. 1. `TruncateDecimalString` has been added as a helper function to truncate the amounts to whichever specified d.p. This has been set to 2 in the menuhanlder 2. The `ParseAndScaleAmount` func will be called after the amount has been truncated to the specified d.p. 3. Tests have been added to show the behavior of different cases.
Alfred-mk merged commit dd56d52f4c into master 2025-06-26 14:07:29 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: grassrootseconomics/sarafu-vise#87
No description provided.