duckduckgo/zeroclickinfo-goodies

Calculator: Add support for Currency math

Closed this issue · 9 comments

The calculator calculates the final price of goods if the input is given in $ but not if the input is given in other currencies. It should calculate the numbers and then add the symbol of the input currency.


IA Page: https://duck.co/ia/view/calculator

@askhubchandani Thanks for the suggestion!

For the near future the Calculator will only support dollars - but after #1927 is sorted I'm planning on implementing a few additional features - including multiple currencies.

@GuiltyDolphin I've assigned you to this for now, if you can't look at it or anything feel free to remove yourself etc

@GuiltyDolphin Can I build it if you do not have time to develop it? I am new here. Please guide me on how to build it.

@askhubchandani Sure! You're more than welcome.

I just want to clear up a few things with the way in which currencies are parsed/handled and then you can add them to your hearts content.

Should be a relatively small PR, I'll additionally add a bit of documentation to make it clear what goes where when extending functionality.

@askhubchandani I'm not sure these changes would be appropriate in the calculator. After some discussion, it would likely be more useful to have these in a dedicated currency Goodie (https://duck.co/ia/view/currency maybe?) that could potentially use some of the calculator's back-end for calculations.

@GuiltyDolphin How will these changes not be appropriate? The currency Goodie is for conversions. It does not perform complete calculations. My intention was that the calculator should be able to add/subtract prices of goods in others currencies(one currency at a time) and give the result to the user and not conversions of different currencies.

@askhubchandani Sorry, yes - that was just an example; we have other currency IAs that may be more appropriate for this use.

One focus for the calculator currently is support for an interactive front-end, rather than extend the back-end functionality further.

An issue that arises with this (and other calculations involving units) is handling them in conjunction with other units (or unitless values), which is something we may wish to consider further in the future.

If we were able to create another Goodie for these calculations, and use the calculator back-end for more 'advanced' calculations, it would allow us to have a more dedicated design that could highlight important information about the currencies (especially when adding different currencies together).

My feeling is still that this should be handled in a separate Instant Answer that could (possibly) interface with the Calculaor's back-end, but I agree it would be possible to add this to the calculator - I'll open this up to more discussion.

Something of this nature could probably be added to the new JS calculator using a library like http://openexchangerates.github.io/accounting.js/

This is now handled at a superficial level. There just isn't the queries to support currency/accounting math at the moment.