merchant-backoffice

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

commit 2c0e1a08404b635904d32b00f445eb0571bbdd20
parent 9d432586989f992220c047be0df18ef05e4e3d45
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu, 27 May 2021 16:03:40 -0300

fixed @gnu-taler/taler-util dependency

Diffstat:
Mpackages/frontend/src/utils/amount.ts | 37++++++++++++-------------------------
Mpnpm-lock.yaml | 2+-
2 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/packages/frontend/src/utils/amount.ts b/packages/frontend/src/utils/amount.ts @@ -56,36 +56,23 @@ 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) } 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) } 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 } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml @@ -1576,7 +1576,7 @@ packages: dev: true /@gnu-taler/taler-util/0.8.2: - resolution: {integrity: sha1-B6/UuryzdS4wsbBtK1vTn/kNAaM=, tarball: https://gitlab.com/api/v4/projects/20136151/packages/npm/@gnu-taler/taler-util/-/@gnu-taler/taler-util-0.8.2.tgz} + resolution: {integrity: sha1-suKMin9qIwQiIAf5n97Bf9siUfM=, tarball: https://gitlab.com/api/v4/projects/20136151/packages/npm/@gnu-taler/taler-util/-/@gnu-taler/taler-util-0.8.2.tgz} dependencies: tslib: 2.2.0 dev: false