Feature request: Add information about smallest coin value Currency #593
                  
                    
                      OhGhie4iew
                    
                  
                
                  started this conversation in
                Ideas
              
            Replies: 1 comment
-
| 
         Hey @OhGhie4iew! Can you walk me through some use cases so I fully understand the problem space? One of the main goals of Dinero.js is to separate data from its final representation. If you want never to display decimal values other than 0.0 and 0.5, you can do this when formatting with  import { dinero, toFormat } from 'dinero.js';
import { SEK } from '@dinero.js/currencies';
const d = dinero({ amount: 525, currency: SEK });
toFormat(d, ({ amount, currency }) => {
  if (amount % 0.5 === 0 || amount % 0.5 === 0) {
    return `${currency.code} ${amount}`;
  }
  return // your rounding logic;
}); | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The smallest coin value currently available in SEK is 0.50 SEK.
So in some cases it makes sense to display 1.37 SEK as 1.50 SEK
To produce correct results when rounding it would make sense that the Currency objects also contains information about the smallest coin value.
Beta Was this translation helpful? Give feedback.
All reactions