Page MenuHomePhabricator

Unify localized number handling
Closed, ResolvedPublic5 Estimated Story Points

Description

The handling of decimal numbers from HTTP requests in the FundraisingFrontend is inconsistent:

  • donation/new expects English-formatted numbers (using a locale-aware parser) and will default to 0 if the number can't be parsed.
  • donation/add expects German-formatted numbers (using a locale-aware parser) and will default to 0 if the number can't be parsed.
  • apply-for-membership expects German-formatted numbers (using simple string-replacement of comma to dot) and has no default.
  • validate-amount expects an integer (Euro Cents)
  • validate-fee can handle both English and German-formated numbers (using simple string-replacement from comma to dot)

My proposal would be to get rid of the existing locale-aware AmountParser and standardize on EuroCents. This will avoid rounding errors. For this solution, the client-side code, both in FundraisingFRontend and in the banners needs to be changed.

Note: This inconsistency has forced us to add workaround code in banners at least 2 times.
When this issue is fixed, check the banner code if the amount is passed on correctly, both to donation/new and to donation/add.

Note: Check for usages of AmountFormatter which will format the amount for rendering it in the template. If the amount is rendered as a string in the template then everything is fine, but if the amount is processed by JavaScript, it needs to re-parse the (German-formatted) amount again.

Note: We don't need to care for backwards compatibility of older banners.

Note: The estimation is made under the assumption that there will only be one skin to be changed.

Event Timeline

Restricted Application added a project: WMDE-FUN-Team. · View Herald TranscriptSep 13 2018, 10:32 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
gabriel-wmde updated the task description. (Show Details)Sep 21 2018, 8:40 AM
gabriel-wmde updated the task description. (Show Details)Dec 12 2018, 3:48 PM
gabriel-wmde triaged this task as High priority.Dec 12 2018, 4:44 PM
gabriel-wmde updated the task description. (Show Details)May 7 2019, 12:32 PM
kai.nissen updated the task description. (Show Details)Jul 1 2019, 10:28 AM
kai.nissen updated the task description. (Show Details)Jul 1 2019, 10:33 AM
kai.nissen set the point value for this task to 5.
kai.nissen closed this task as Resolved.Mar 13 2020, 11:07 AM