Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more currencies to format.js#money #10

Open
beninsydney opened this issue Apr 17, 2022 · 0 comments
Open

Add more currencies to format.js#money #10

beninsydney opened this issue Apr 17, 2022 · 0 comments

Comments

@beninsydney
Copy link
Contributor

beninsydney commented Apr 17, 2022

This is very simple contribution for people familiar with other currencies, just add yours into the switch statement in format.js for the Stripe Connect and Stripe Subscriptions modules --

https://github.com/layeredapps/dashboard/blob/main/src/format.js

   function money (amount, currency) {
      if (!currency) {
        return null
      }
      currency = currency.toLowerCase()
      switch (currency) {
        case 'usd':
        case 'aud':
        case 'nzd':
        case 'cad':
        case 'hkd':
        case 'sgd':
          return amount >= 0 ? `$${(amount / 100).toFixed(2)}` : `-$${(amount / -100).toFixed(2)}`
        case 'eur':
          return amount >= 0 ? `€${(amount / 100).toFixed(2)}` : `-€${(amount / -100).toFixed(2)}`
        case 'gbp':
          return amount > 0 ? `£${(amount / 100).toFixed(2)}` : `-£${(amount / -100).toFixed(2)}`
        case 'jpy':
          return amount > 0 ? `¥${(amount / 100).toFixed(2)}` : `-¥${(amount / -100).toFixed(2)}`
        default:
          return amount
      }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant