Money

Sean DeNigris

Hernan W. [wrote](http://forum.world.st/Money-units-tp68797p68802.html) *"We use Aconcagua as the base measure model for our financial applications... The idea of aconcagua is to represent any kind of measure. All our financial math is based on it... for example an interest rate is an instance of InterestRate (not included in Aconcagua) that is a subclass of Evaluation (at the begging called Formula) that is polimorphic with any other measure. That way all the financial formulas are reified and they can participate in any math operation with other measures, evaluations or even numbers... (measures and numbers are polimorphic also). Let me know if you have any problem. "* # Other Work - Avi Bryant's Money package on SqS [as mentioned by sebastian Sastre](http://forum.world.st/Money-units-tp68797.html). In [Avi's words](http://forum.world.st/Smalltalk-float-to-currency-how-to-tp86320p86326.html), *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... * - <http://www.smalltalkhub.com/#!/~MarcusDenker/Units> - has pre-defined units, perhaps in contrast to Aconcagua? - [From Ben Coman in 2012](http://forum.world.st/Quantities-and-Units-tp4274976.html): - http://www.squeaksource.com/Units.html - http://www.cincomsmalltalk.com/publicRepository/Quantities.html - http://www.smalltalking.net/goodies/Dolphin/ (scroll to bottom) - http://comments.gmane.org/gmane.comp.lang.smalltalk.squeak.general/55894 - <http://www.squeaksource.com/Money.html>. [According to Paul DeBruicker](http://forum.world.st/Pharo-dev-Monetary-package-tp4692670p4693053.html), *"For anybody who cares it originally comes from last chapter of Smalltalk Best Practices Patterns by Kent Beck and was uploaded by Avi Bryant. I've been decreasing the code quality for a little while. ;)* - David Shaffer posted [a little solution](http://forum.world.st/Smalltalk-float-to-currency-how-to-tp86320p86325.html) on the Seaside ML - Chris Muller [mentioned](http://forum.world.st/Re-Money-ScaledDecimal-is-it-really-appropriate-tp86365.html) that *Martin Fowler weighs in on a Money implementations in his book, "Analysis Patterns".* In 2015, I made [an appeal on Pharo Users](http://forum.world.st/Modeling-Money-Units-tp4838614.html) to clarify the situation, but got no answer: *There are several tools: Aconcagua, Money, Units; and at least two classes to overcome the imprecision of Floats: ScaledDecimal, FixedDecimal... I found one thread where Hernan said they use Aconcagua [1], another from Squeak implying that ScaledDecimal is broken [2]. A third seemed to say that FixedDecimal would be better [3], which I hadn't heard in the handful of times money has been discussed on list (usually ScaledDecimal comes up). For a simple case where someone wanted to write a small personal accounting app, which tool and which type would be the best place to start? Thanks! [1] http://forum.world.st/Money-units-tp68797p68800.html [2] http://forum.world.st/Seaside-Re-Money-ScaledDecimal-is-it-really-appropriate-tt46446.html [3] http://forum.world.st/Pharo-dev-Monetary-package-tt4692670.html* # Units - [Positive experience report](http://forum.world.st/Pharo-dev-Monetary-package-tp4692670p4692706.html) by Denis Kudriashov: *In past I used Units package to model money. It is very convinient to calculate currency exchange operations.* # Chris Cunningham Explains Fixed Decimal [From Pharo Dev 2013](http://forum.world.st/Pharo-dev-Monetary-package-tp4692670p4692890.html) *First, is FixedDecimal used in the Money package? I didn't see is referenced there, so I'm curious where it came from. There is a definite different between ScaledDecimal and FixedDecimal. ScaledDecimal (unless it's been changed recently) keeps the full precision of the original number. FixedDecimal (and Money, from my short perusal of it), do not - they make sure that the displayed value is exactly what the internal value is. As an example, check out the following: x := ((1/3) asScaledDecimal: 2). x `> 0.33s2 x = (1/3) `> true ((33/100) asScaledDecimal: 2) `> 0.33s2 x = ((33/100) asScaledDecimal: 2) `> false (!) x + x `> 0.67s2 (!) In general, the last 2 statements are NOT what you want when dealing with Money - if you have an amount, it is a definite amount, and not an approximate amount. (With the possible exceptions of interim results - but for those, you probably need strict control over exactly how precise the interim results are - which isn't readily available in ScaleDecimal). This is the main reason I built the FixedDecimal package on SqueakSource. There, the above statements show: x := ((1/3) asFixedDecimal: 2). x `> 0.33 x = (1/3) `> true ((33/100) asFixedDecimal: 2) `> 0.33 x = ((33/100) asFixedDecimal: 2) `> true x + x `> 0.66 From my perspecive, ScaledDecimal is great when you want to keep as much precision as possible, but need to SHOW less precision. It reminds me of science, where you have this measurement that is way more precise than you can really measure, so you 'scale' it back to a precision that is reliable.*

~