Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

fix: Don't assume that scale=0 means "show cents" #52

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions lib/CurrencyDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export default {
BIF: {
format: "%s%v",
symbol: "$",
scale: 0
scale: 0,
showCents: true
},
BMD: {
format: "%v %s",
Expand Down Expand Up @@ -114,7 +115,8 @@ export default {
symbol: "p.",
decimal: ",",
thousand: ".",
scale: 0
scale: 0,
showCents: true
},
BZD: {
format: "%s%v",
Expand Down Expand Up @@ -180,7 +182,8 @@ export default {
DJF: {
format: "%v %s",
symbol: "Fdj",
scale: 0
scale: 0,
showCents: true
},
DKK: {
format: "%s%v",
Expand Down Expand Up @@ -261,7 +264,8 @@ export default {
GNF: {
format: "%v %s",
symbol: "FG",
scale: 0
scale: 0,
showCents: true
},
GTQ: {
format: "%s%v",
Expand Down Expand Up @@ -302,7 +306,8 @@ export default {
JPY: {
format: "%s%v",
symbol: "¥",
scale: 0
scale: 0,
showCents: true
},
KWD: {
format: "%s%v",
Expand All @@ -311,7 +316,8 @@ export default {
KRW: {
format: "%s%v",
symbol: "₩",
scale: 0
scale: 0,
showCents: true
},
KZT: {
format: "%v %s",
Expand Down Expand Up @@ -409,7 +415,8 @@ export default {
XAF: {
format: "%v %s",
symbol: "CFA",
scale: 0
scale: 0,
showCents: true
},
XCD: {
format: "%s%v",
Expand All @@ -418,6 +425,7 @@ export default {
XOF: {
format: "%v %s",
symbol: "CFA",
scale: 0
scale: 0,
showCents: true
}
};
2 changes: 1 addition & 1 deletion lib/formatMoney.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function formatMoney(price, currencyCode = "USD") {

// If there are no decimal places, in the case of the Japanese Yen, we adjust it here.
let priceToFormat = price;
if (currencyInfo.scale === 0) {
if (currencyInfo.showCents) {
priceToFormat = price * 100;
}

Expand Down