merchant-backoffice

ZZZ: Inactive/Deprecated
Log | Files | Refs | Submodules | README

commit 1732185ac1d1dcc783b8f2489f2ce333b5254d92
parent 4726d03a34f95085f3bae9b86037c91abe913a20
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu, 27 May 2021 15:29:07 -0300

revert until fix wallet-core publishing

Diffstat:
Mpackages/frontend/src/utils/amount.ts | 50+++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/packages/frontend/src/utils/amount.ts b/packages/frontend/src/utils/amount.ts @@ -56,36 +56,36 @@ export function mergeRefunds(prev: MerchantBackend.Orders.RefundDetails[], cur: } export const multiplyPrice = (price: string, q: number) => { - const a = Amounts.parseOrThrow(price) - const r = Amounts.mult(a, q) - return Amounts.stringify(r.amount) - // const [currency, value] = price.split(':') - // const total = parseInt(value, 10) * q - // return `${currency}:${total}` + // const a = Amounts.parseOrThrow(price) + // const r = Amounts.mult(a, q) + // return Amounts.stringify(r.amount) + const [currency, value] = price.split(':') + const total = parseInt(value, 10) * q + return `${currency}:${total}` } export const subtractPrices = (one: string, two: string) => { - const a = Amounts.parseOrThrow(one) - const b = Amounts.parseOrThrow(two) - const r = Amounts.sub(a, b) - return Amounts.stringify(r.amount) - // const [currency, valueOne] = one.split(':') - // const [, valueTwo] = two.split(':') - // return `${currency}:${parseInt(valueOne, 10) - parseInt(valueTwo, 10)}` + // const a = Amounts.parseOrThrow(one) + // const b = Amounts.parseOrThrow(two) + // const r = Amounts.sub(a, b) + // return Amounts.stringify(r.amount) + const [currency, valueOne] = one.split(':') + const [, valueTwo] = two.split(':') + return `${currency}:${parseInt(valueOne, 10) - parseInt(valueTwo, 10)}` } export const rate = (one: string, two: string) => { - const a = Amounts.parseOrThrow(one) - const b = Amounts.parseOrThrow(two) - const af = Amounts.toFloat(a) - const bf = Amounts.toFloat(b) - return af / bf - // const [, valueOne] = (one || '').split(':') - // const [, valueTwo] = (two || '').split(':') - // const intOne = parseInt(valueOne, 10) - // const intTwo = parseInt(valueTwo, 10) - // if (!intTwo) return intOne - // if (!intOne) return 0 - // return intOne / intTwo + // const a = Amounts.parseOrThrow(one) + // const b = Amounts.parseOrThrow(two) + // const af = Amounts.toFloat(a) + // const bf = Amounts.toFloat(b) + // return af / bf + const [, valueOne] = (one || '').split(':') + const [, valueTwo] = (two || '').split(':') + const intOne = parseInt(valueOne, 10) + const intTwo = parseInt(valueTwo, 10) + if (!intTwo) return intOne + if (!intOne) return 0 + return intOne / intTwo }