mazipan / vue-currency-filter

🍒 Lightweight vue currency filter based on accounting.js
https://mazipan.github.io/vue-currency-filter/
MIT License
246 stars 29 forks source link

Feature Request: Add function to preprocess amount #205

Open DArrigoni opened 4 years ago

DArrigoni commented 4 years ago

My project uses a lot of dollar amounts but they are all stored on the server as "in cents." ie. $10.00 would be stored as 1000.

Currently, I have to pass these amounts through two filters, one to convert the amount from "in cents" to "in dollars" before passing it into the currency filter. It would be nice to be able to provide the currency filter config a function to do this.

Example:

Vue.use(VueCurrencyFilter, {
  symbol: "$",
  thousandsSeparator: ",",
  fractionCount: 2,
  fractionSeparator: ".",
  symbolSpacing: false,
  convert: function (amount) { return amount / 100 }
})

If you feel this is within the scope of the vue-currency-filter, and I would understand if you don't feel it is, I would be happy to give this shot and send you a pull request.

mazipan commented 4 years ago

Can you help to check the code? Maybe you can build it for your needs. I think it's good addition.

dsfx3d commented 4 years ago

@mazipan Is this feature still open for a PR?

dsfx3d commented 4 years ago

The project has great utility for some use cases but we need to work on the code quality as well to maintain a good developer experience for all potential contributors. Should I make a PR with a linting set up first? There are lint errors in almost all modules.

mazipan commented 4 years ago

Yes sure

kissu commented 3 years ago

Any news on this one ? 🤗