Currency outputs exchange rates as floats, because those are application-neutral (Integer notations for decimal values are more application-specific). However, floats have their own quirks (loss of precision). A solution to both problems would be to output decimal values as strings, but in a decimal notation. As Currency does not do computations, but only passes on data, this should ensure data integrity and application-agnosticism.

Comments

xano’s picture

Assigned: Unassigned » xano
Status: Active » Needs review
StatusFileSize
new15.99 KB

Updated all the tests and most of the code. To-dos:
- Update bartfeenstra/currency with string exchange rates
- Remove calculating reverse exchange rates
- Find a way for Currency::getRoundingStep() to return something else than a float, and to use that return value to round amounts. Consider removing the rounding feature completely. Calculating the rounding step may actually be useful enough to keep.
- Update validating for the currency_amount form element.
- Update database columns that are still floats.

Status: Needs review » Needs work

The last submitted patch, currency_1937356_00.patch, failed testing.

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new58.19 KB

The patch includes a composer update for bartfeenstra/currency, which partly explains the size.

xano’s picture

Status: Needs review » Fixed
xano’s picture

Status: Fixed » Active

currency_form_currency_amount_validate() compares values as strings instead of using bccomp().

xano’s picture

Status: Active » Needs review
StatusFileSize
new1.67 KB

Status: Needs review » Needs work

The last submitted patch, currency_1937356_02.patch, failed testing.

xano’s picture

Status: Needs work » Needs review

#6: currency_1937356_02.patch queued for re-testing.

xano’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xano’s picture

Assigned: xano » Unassigned