Cryptocurrency Supporting
26. 12. 2024
Using the System for Cryptocurrency Accounting
To enable cryptocurrency accounting, the system must support customizing the fraction of different currencies and calculating and storing cryptocurrency transactions with exact precision, without rounding. This ensures accurate calculations for cryptocurrencies such as Bitcoin.
Fraction
- The Currency entity contains a fraction field.
- A currency fraction represents a smaller unit of the currency, corresponding to a part of the whole currency value.
- Users can specify fractions when creating a new asset (currency).
Example:
- USD fraction is 100 (representing cents).
- Bitcoin fraction is 100,000,000 (representing satoshis).
- Back-end Handling: The fraction calculation is performed on the back end, and the front end receives the amount already calculated with the correct fraction.
- Front-end Limitation: Currently, the fraction parameter is not used by the front end. Instead, validation for input amounts has been extended to support up to 18 digits on the front end.
Scale
- The currency scale determines the number of decimal places used for calculations.
- The system calculates the scale based on the specified currency fraction.
Example:
- USD scale is 2 (representing two decimal places for cents).
- Bitcoin scale is 20 (representing satoshis).
- System Usage: The currency scale is included in in-system calculations, ensuring exact precision.
Precision in Calculations
- The system calculates and stores cryptocurrency transactions with exact precision, without rounding, to prevent inaccuracies.
- Numeric columns support 18 digits before the decimal separator and up to 20 decimal places for precision.