Money, Progress Bars & Old Macs (Sep 22)

Our staff has gradually been getting the Reconcile and Pay Bills commands to work. It has taken us down many different rabbit holes. Working on very old parts of the accounting software code.

When we started to program Goldenseal, the C++ language was young. Things like dates, time, currency and text required long stretches of home-made code to function. They are not simple.

Take money, for example. First of all, it’s important how you store it. Computers have “float” values for decimals, but they are dangerous for money amounts. The problem is, floats can’t store cents and other fractions precisely. It’s a basic number problem. 1/100 is not an even number of binary bits, so you can only get close to it, never exact. If you ever see something like $99.999999997 or $100.0000000013 on a website, their programmers used floats for money and forgot to round them.

For Goldenseal accounting, we wrote a CMoney class that stores dollars in 32-bit integers, and pennies in 16-bits. That way it’s exact. CMoney can handle up to $4 billion, and down to 1/100th of a penny. No risk of weird rounding errors. Some day we probably will switch to 64-bit integers and extend the ranges, but it will mean a ton of rewriting and testing, for not much gain.

Money has more quirks. There are dozens of currency symbols. Some are on the left, and some on the right. The decimal point may be a period, or a comma. The thousands separator may be a comma, period, something else, or nothing. In some countries the separators aren’t every 3 digits.

Back in the early 90s, we wrote a lot of raw C++ code to handle all that. Then Apple released easier ways to localize for different countries- money, dates, other stuff. We rewrote some of the interface to use that. Then rewrote it again for Cocoa. Now we are rewriting yet again to use Qt.

Each framework does basically the same stuff, but always with quirks and gotchas. For example, Qt has built-in currency formatting, but it only accepts floats. No option for integer dollars and pennies. It probably has built-in rounding to avoid the $99.999999997 problem, but maybe it doesn’t. We’ll have to test it to find out.

It’s also time to redo progress bars. When tasks take a long time, the current Goldenseal puts up a small window with a moving bar. Sometimes it has a Stop button. Everything runs faster now, so TurtleSoft Pro will just have a small built-in progress bar at the bottom of the window. Most of the time it will just flash by, and a pop-up box would be annoying. The new method is simpler, but it means rewriting about 100 different places that show the bar.

For the actual accounting work, the new interface connects with Reconcile and Pay Bills business logic that is 20 years old. To understand how those work, we use the debugger to step through the current Goldenseal source code. 32-bit Goldenseal runs on anything pre-2019, but the Xcode project that builds it requires pre-2009.

We were down to just two older Macs able to build the app, then one of those died. It’s getting too risky. Fortunately, there is plenty of older hardware on eBay. The challenge is to set them up with MacOS Leopard. Or else figure how to update the project so it runs on Snow Leopard, which is easier to find and install.

Fun trips down memory lane…

Dennis Kolva
Programming Director
TurtleSoft.com

Author: Dennis Kolva

Programming Director for Turtle Creek Software. Design & planning of accounting and estimating software.