diff --git a/currency.go b/currency.go index e75d6ff..74b7c58 100644 --- a/currency.go +++ b/currency.go @@ -244,7 +244,7 @@ func newCurrency(code string) *Currency { // GetCurrency returns the currency given the code. func GetCurrency(code string) *Currency { - return currencies.CurrencyByCode(code) + return currencies.CurrencyByCode(strings.ToUpper(code)) } // Formatter returns currency formatter representing diff --git a/money_test.go b/money_test.go index 45c5fd0..76bf447 100644 --- a/money_test.go +++ b/money_test.go @@ -804,6 +804,16 @@ func TestNewFromFloat(t *testing.T) { t.Errorf("Expected currency %s got %s", EUR, m.currency.Code) } + m = NewFromFloat(12.34, "eur") + + if m.amount != 1234 { + t.Errorf("Expected %d got %d", 1234, m.amount) + } + + if m.currency.Code != EUR { + t.Errorf("Expected currency %s got %s", EUR, m.currency.Code) + } + m = NewFromFloat(-0.125, EUR) if m.amount != -12 {