Commit 61fec0ab authored by Antoine's avatar Antoine
Browse files

Ensure -0 and 0 are displayed the same everywhere in the client and the alerts/reports. Fixes #838.

parent 1dea1523
......@@ -5,8 +5,7 @@ const ColoredAmount = props => {
let { amount, formatCurrency } = props;
// Ensure 0.00 and -0.00 are displayed the same.
amount = Math.abs(amount) < 0.001 ? 0 : amount;
let colorClass = amount < 0 ? 'negative' : 'positive';
let colorClass = amount < 0 && Math.abs(amount) >= 0.001 ? 'negative' : 'positive';
return <span className={`amount ${colorClass}`}>{formatCurrency(amount)}</span>;
};
......
......@@ -121,7 +121,13 @@ export const localeComparator = (function() {
export const currency = {
isKnown: c => typeof findCurrency(c) !== 'undefined',
symbolFor: c => findCurrency(c).symbol,
makeFormat: c => amount => currencyFormatter(amount, { code: c })
makeFormat: c => {
let { decimalDigits } = findCurrency(c);
return amount => {
let am = Math.abs(amount) < Math.pow(10, -decimalDigits - 2) ? 0 : amount;
return currencyFormatter(am, { code: c });
};
}
};
export const UNKNOWN_OPERATION_TYPE = 'type.unknown';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment