squants icon indicating copy to clipboard operation
squants copied to clipboard

Support for other currencies

Open joesan opened this issue 2 years ago • 2 comments

I tried the library for dealing with some Forex and I was hitting a "Not Implemented Exception" where I was trying ti read That bhat (THB) into a CurrencyCenverter with Money.parser(....). Is there a reason why only limited Currency types are supported?

joesan avatar May 28 '22 04:05 joesan

It looks THB is not in the library.  I assume you created it?

If that's the case, you will need to override the defaultMoneyContext to include your currency as well.  As it is, the defaultMoneyContext only includes currencies defined in the library.

It's a case class, so you should be able to do something like

  implicit val myMoneyContext = defaultMoneyContext.copy(currencies = defaultCurrencySet ++ THB)

garyKeorkunian avatar May 29 '22 00:05 garyKeorkunian

Thanks for the hint. I think I did that already but nevertheless was running into some exceptions:

squants_error

I'm using the version: "1.6.0" and when I run, I get the Not Implemented Exception:

scala.NotImplementedError: an implementation is missing
	at scala.Predef$.$qmark$qmark$qmark(Predef.scala:344)
	at squants.market.Money$.units(Money.scala:418)
	at squants.market.Money$.units(Money.scala:393)
	at squants.Dimension.squants$Dimension$$QuantityString(Dimension.scala:75)
	at squants.Dimension.squants$Dimension$$QuantityString$(Dimension.scala:75)
	at squants.market.Money$.squants$Dimension$$QuantityString$lzycompute(Money.scala:393)
	at squants.market.Money$.squants$Dimension$$QuantityString(Money.scala:393)
	at squants.Dimension.parseString(Dimension.scala:71)
	at squants.Dimension.parseString$(Dimension.scala:69)
	at squants.market.Money$.parseString(Money.scala:393)

joesan avatar May 31 '22 05:05 joesan