Skip to content

Error when managing some currency symbols as Swiss Franc #9404

Open
@psynd

Description

@psynd

Issue

While dealing with the currencies, there is a lack of escape char.
Let's take two examples:

  • The USD is translated with the symbol $
  • The Euro is translated with the symbol €

In these two examples, the symbols don't have any mathematical sense.
If we take the Swiss Franc (ISO -> CHF), the symbol used is the " - " (dash).
While calculating quotes, contracts, invoices and so on, where a "Discount" is present, a standard " - " (minus) is added in front.
A negative amount is managed as - ($) DiscountAmount, or - () DiscountAmount.
If the currency used is the CHF, for a discount is added the "minus", the currency symbol "dash", and then the discount amount.
This transforms the previous sequence into - (-) DiscountAmount.
To have in sequence the minus and then the symbol dash, it makes - - = +, so the two negative symbols are transformed into a positive, because probably is missing a separator or some kind of escaping while handling the currency symbol, so the Discount is "added" instead of being "subtracted" to the total amount.

Expected Behavior

All currencies, except those like the Swiss Franc using the "minus" as symbol, work properly, and also a discount applied to the Swiss Franc should be considered as "negative".

Actual Behavior

Using the Swiss Franc, the Discount turns from a negative amount to a positive amount, making the final amount higher than before the discount.

Possible Fix

We modified the Swiss Franc symbol using "CHF", but this is not the standard Swiss Franc symbol.
With our modification the discounts are correctly handled as negative amounts, but this cannot be a final solution.

Steps to Reproduce

  1. Add to the system the Swiss Franc as symbol
  2. Create a quote, an invoice or a contract
  3. be sure that the selected currency is the Swiss Franc
  4. put any amount and after add a discount either in amount or percentage: the discount amount will appear as positive instead of negative.

Context

Low impact, but still present.

Your Environment

This is system independent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: ModuleIssues & PRs related to modules that do not have specific labelPriority:ImportantIssues & PRs that are important; broken functions, errors - there are workaroundsType: BugBugs within the core SuiteCRM codebase

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions