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

Format inconsistencies between string and number inputs #42

Open
kcarmonamurphy opened this issue Dec 8, 2021 · 0 comments
Open

Format inconsistencies between string and number inputs #42

kcarmonamurphy opened this issue Dec 8, 2021 · 0 comments

Comments

@kcarmonamurphy
Copy link

kcarmonamurphy commented Dec 8, 2021

Hi Milind - many thanks for this great addon which has been very useful to us in our app!

I discovered an inconsistency in the way that this addon parses string values vs number values. Given the following config:

  // app/initializers/accounting.js
  import { currency, number } from 'accounting/settings'

  export default {
    name: 'accounting.js',
    initialize: function() {
      currency.symbol = '$'
      currency.format = {
        pos: '%v %s',
        neg: '-%v %s',
        zero: '%v %s'
      }
      currency.decimal = ','
      currency.thousand = ' '
      number.decimal = ','
      number.thousand = ' '
      currency.precision = 0
    }
  }

The output of {{format-money "43.7" precision=2}} is: 437.00, while the output of {{format-money 43.7 precision=2}} is 43.70

I've observed the same issue with format-number.

The issue is NOT present with the following config:

      currency.symbol = '$'
      currency.format = {
        pos: '%s%v',
        neg: '-%s%v',
        zero: '%s%v',
      }
      currency.decimal = '.'
      currency.thousand = ','
      number.decimal = '.'
      number.thousand = ','
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