On 24/05/2018 12:03 PM, Mike Dewhirst wrote:
> On 23/05/2018 12:31 PM, Simon McConnell wrote:
>> I'm in a similar boat at the moment. There
>> is https://github.com/vimeo/py-money too.
>
> I looked at that but it probably won't ever support exchange rates.
> Not sure yet if that is a show stopper because maybe forex is a
> separate thing anyway. I do need exchange rates in another project and
> I'd like choose a MoneyField which works in all projects.
On reflection I don't think exchange rates are any sort of show-stopper.
I either agree on an exchange rate with the client ahead of time and do
a forex deal without a rate (and wear the loss or gain when actually
exchanged) or bill in AUD and expect AUD to be remitted. I don't think I
want the complication of the MoneyField doing what someone else thinks
should happen.
>
>> Note that django-money uses py-moneyed which does not yet use Babel,
>> so rendering of the correct symbol is limited to a few hardcoded
>> currencies.
But py-moneyed does claim a complete dictionary of ISO 4217 currencies.
It also supports Python 2.7 which is useful for me because I haven't yet
rebuilt apache/mod_wsgi for py3 on my Ubuntu VMs. I wish there was a
pill to cure procrastination.
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/O51wKkudE_U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/65f7387c-aa75-f29c-9f99-74095d5e9c7d%40dewhirst.com.au.
On dinsdag 29 mei 2018 11:03:56 CEST Mike Dewhirst wrote:
> Also, despite using decimal.Decimal under the covers it wants its money
> as strings.
>
> Python 3.6.3
>
> >>> from money import money
> >>> print(money.Money(23.45, 'AUD'))
>
> AUD 23.449999999999999289457264239899814128875732421875
>
> >>> print(money.Money('23.45', 'AUD'))
>
> AUD 23.45
No, that's decimal.Decimal and floats being an approximation:
>>> from decimal import Decimal
>>> Decimal('23.45')
Decimal('23.45')
>>> Decimal(23.45)
Decimal('23.449999999999999289457264239899814128875732421875')
>>> print('{:.48f}'.format(23.45))
23.449999999999999289457264239899814128875732421875
>>> print('{:.55f}'.format(23.45))
23.4499999999999992894572642398998141288757324218750000000
So decimal.Decimal's constructor converts strings to decimal numbers with as much precision as given. It also applies to floats, except that floats have more precision then typed.
--
Melvyn Sopacua