B2Bitcoin / beBOP

Marvelous p2p bitcoin-based online sales platform
https://be-bop.io
GNU Affero General Public License v3.0
15 stars 3 forks source link

🦋 Manage decimals on price #1461

Open Tirodem opened 5 days ago

Tirodem commented 5 days ago

image Current use (in FR & CH) is to display "5.90" instead of "5.9". But some countries would rather "5.9" instead of "5.90". We need to create a setting in /admin/config to allow the be-BOP owner to do as he/she wants. Plus, we need to study if there's countries with 0 or 3 decimals on their currencies.

coyotte508 commented 5 days ago

We already have FRACTION_DIGITS_PER_CURRENCY

export const FRACTION_DIGITS_PER_CURRENCY = Object.freeze({
    BTC: 8,
    CHF: 2,
    EUR: 2,
    USD: 2,
    ZAR: 2,
    XOF: 2,
    XAF: 2,
    CDF: 2,
    SAT: 0
}) satisfies Record<Currency, number>;

It's something that needs to be edited when adding a new currency anyway.

We can base ourself on this for the number of digits

Tirodem commented 5 days ago

Sure it's a super good base to work on. We just need to avoid situations where we displayed that something cost 2.1200000000 BTC if price is 2.12 only (rare case I admin due to conversion rate and BTC amount, but on BTC as price reference currency store it can become a problem).