Smalltalk float to currency how to ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Dmitry Dorofeev
Thanks Avi,

I just wondering can I use
Money amount: 15.89 currency: '£'

to use with HTML rendering (same applies to Euro sign)

or do we need just different method to rendering HTML friendly
version of currency symbols based on name of currency ?
like Dictionary with
'USD' -> $
'GBP' -> '£'
'EUR' -> '€'
etc

-Dmitry.

Avi Bryant wrote:

>
> On Feb 2, 2006, at 9:29 AM, David Shaffer wrote:
>
>>
>> I'd like to second what I believe Colin said about using integers to
>> represent money.  If you need four digits then that dictates the scale
>> of your integers.  Maybe ScaledDecimals would do the job, don't know
>> anything about them, but my experience dictates that it only takes 10
>> minutes to put together a Money (and/or Currency) class based on this
>> integer representation and it is well worth the effort.  Attached  is one
>> that I've used in the past...maybe not as robust as you need but you
>> could probably hack it into your 4-digit form faster than you could
>> learn about ScaledDecimal...
>>
>> Maybe somewants to post a more industry hardened version :-)
>
>
> I wouldn't call it industry hardened, but I've posted what we use in  
> Dabble to http://squeaksource.com/Money .  It uses the MoneyBag  
> approach to dealing with currency that I remember seeing as a pattern  
> somewhere...
>
> Avi
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Avi  Bryant

On Feb 3, 2006, at 1:25 AM, Dmitry Dorofeev wrote:

> Thanks Avi,
>
> I just wondering can I use Money amount: 15.89 currency: '£'
>
> to use with HTML rendering (same applies to Euro sign)
>
> or do we need just different method to rendering HTML friendly
> version of currency symbols based on name of currency ?
> like Dictionary with
> 'USD' -> $
> 'GBP' -> '£'
> 'EUR' -> '€'

The latter, I think.

We should probably have a Currency object, in fact, to encapsulate  
some of that logic.  Not sure whether to have a subclass per currency  
or something simpler...

Avi
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Dmitry Dorofeev


Avi Bryant wrote:

>
> On Feb 3, 2006, at 1:25 AM, Dmitry Dorofeev wrote:
>
>> Thanks Avi,
>>
>> I just wondering can I use Money amount: 15.89 currency: '£'
>>
>> to use with HTML rendering (same applies to Euro sign)
>>
>> or do we need just different method to rendering HTML friendly
>> version of currency symbols based on name of currency ?
>> like Dictionary with
>> 'USD' -> $
>> 'GBP' -> '£'
>> 'EUR' -> '€'
>
>
> The latter, I think.
>
> We should probably have a Currency object, in fact, to encapsulate  some
> of that logic.  Not sure whether to have a subclass per currency  or
> something simpler...
>
> Avi

Ok, here is the situation: I need currency support in Seaside or Squeak.
But I am new to Smalltalk and have no idea what may be 'something simpler'.
Could you please tell me some directions like 'subclass ABC and implement
methods to convert USD to $ sign preferably named convertCode:'.
If that gonna be part of Seaside, fine.
If it is easy I will do my best to follow your directions and send back my code.
(my first contribution!) BTW I am ready to consult standards bodies to fetch
all currency symbols in UTF8 encoding! And all matched 3 letters currency codes.
So probably it will be one class handling all associations for the planet ?

Thanks.
-Dmitry
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Cees De Groot
On 2/3/06, Dmitry Dorofeev <[hidden email]> wrote:
> Ok, here is the situation: I need currency support in Seaside or Squeak.

Make a class Currency and a class Amount. Currency has:
- description ("US Dollars")
- ISO currency code ("USD")
- common currency code ("$" or "US$")
- code to print amounts.
- number of decimals, if any.

Amount has:
- a ScaledDecimal
- a Currency
- print code will be dispatched to Currency.

Bonus points for constructor methods in Number so you can write '12 dollars'.
Double bonus points for hooking up to xe.com or similar so you can
write '(12 dollars + 23 pounds) asEuros'.
And finally triple bonus points for making amounts and currency
conversions date-aware (I think I have some pointers to time travel
patters in my blog).

Note that this quickly gets hairy and application specific. That, plus
the fact that Squeak is not primarily a business-oriented development
environment, is probably the cause that there's no standard package
for this stuff.

Of course, by the time you're done, we'll welcome your publishing this
on SqueakMap :)
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Esteban A. Maringolo
2006/2/3, Cees De Groot <[hidden email]>:
> (I think I have some pointers to time travel
> patters in my blog).

Can you give me a link to them?

Regards,

--
Esteban A. Maringolo
[hidden email]
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Cees De Groot
http://www.manfred-lange.com/publications/TimeTravel.pdf

I think I have a Squeak implementation floating around somewhere of
the Perspective/Edition stuff. With tests, even :)

On 2/3/06, Esteban A. Maringolo <[hidden email]> wrote:

> 2006/2/3, Cees De Groot <[hidden email]>:
> > (I think I have some pointers to time travel
> > patters in my blog).
>
> Can you give me a link to them?
>
> Regards,
>
> --
> Esteban A. Maringolo
> [hidden email]
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Esteban A. Maringolo
Thanks Cees,

2006/2/3, Cees De Groot <[hidden email]>:
> http://www.manfred-lange.com/publications/TimeTravel.pdf

I'm looking for a referenced paper:
"[AJ97] Francis Anderson and Ralph Johnson, Tree with History"
presented in PloP 97, if somebody has it or knows where I can found
it, please contact me.

Thanks.

--
Esteban A. Maringolo
[hidden email]
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Jason Rogers-4
In reply to this post by Cees De Groot
Wonderful.  I sign up to implement this.  It will be a fun exercise.
Should I create a project in SqueakSource called Currency?  Avi would
you prefer me to augment your Money package?

On 2/3/06, Cees De Groot <[hidden email]> wrote:

> http://www.manfred-lange.com/publications/TimeTravel.pdf
>
> I think I have a Squeak implementation floating around somewhere of
> the Perspective/Edition stuff. With tests, even :)
>
> On 2/3/06, Esteban A. Maringolo <[hidden email]> wrote:
> > 2006/2/3, Cees De Groot <[hidden email]>:
> > > (I think I have some pointers to time travel
> > > patters in my blog).
> >
> > Can you give me a link to them?
> >
> > Regards,
> >
> > --
> > Esteban A. Maringolo
> > [hidden email]
> > _______________________________________________
> > Seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>


--
Jason Rogers

"Where there is no vision, the people perish..."
    Proverbs 29:18
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Avi  Bryant

On Feb 3, 2006, at 10:11 AM, Jason Rogers wrote:

> Wonderful.  I sign up to implement this.  It will be a fun exercise.
> Should I create a project in SqueakSource called Currency?  Avi would
> you prefer me to augment your Money package?

Whatever's easiest for you - but even if it's a different package it  
should probably go into the same SqueakSource project.  I'll open it  
up so anyone can write to it.

Avi
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Jason Rogers-4
On 2/3/06, Avi Bryant <[hidden email]> wrote:

>
> On Feb 3, 2006, at 10:11 AM, Jason Rogers wrote:
>
> > Wonderful.  I sign up to implement this.  It will be a fun exercise.
> > Should I create a project in SqueakSource called Currency?  Avi would
> > you prefer me to augment your Money package?
>
> Whatever's easiest for you - but even if it's a different package it
> should probably go into the same SqueakSource project.  I'll open it
> up so anyone can write to it.
>
> Avi

Thanks.

--
Jason Rogers

"Where there is no vision, the people perish..."
    Proverbs 29:18
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Money ScaledDecimal is it really *appropriate* ?

Mark A. Schwenk
In reply to this post by Esteban A. Maringolo
Esteban A. Maringolo wrote:

> Thanks Cees,
>
> 2006/2/3, Cees De Groot <[hidden email]>:
>> http://www.manfred-lange.com/publications/TimeTravel.pdf
>
> I'm looking for a referenced paper:
> "[AJ97] Francis Anderson and Ralph Johnson, Tree with History"
> presented in PloP 97, if somebody has it or knows where I can found
> it, please contact me.
>
> Thanks.

According to Ralph Johnson, it appears that the referenced paper was
submitted but not published as part of that conference. A revised and
expanded version was presented as "A Collection of History Patterns" by
Francis Anderson in the PLoP '98 conference. See

        http://hillside.net/plop/plop98/final_submissions/

The PDF version of this new paper is available at

        http://hillside.net/plop/plop98/final_submissions/P63.pdf

There are many other good papers available through

        http://www.hillside.net/plop/pastconferences.html

-Mark Schwenk
  WellThot Inc.
  PLoP 2003 Conference Chair
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
12