From bf45e531699de7e06f10df49f999d0a1277a5ece Mon Sep 17 00:00:00 2001 From: Wilfred Asomani Date: Fri, 17 Mar 2023 14:37:28 +0000 Subject: [PATCH] satellite/{web,payments}: display correct stripe balance This correctly displays the stripe balance in dollars, which was previously displayed in cents. Change-Id: Ifb14a63a90d3701201c616780cee466525c8be18 --- satellite/payments/balance.go | 2 +- .../account/billing/billingTabs/Overview.vue | 4 ++-- web/satellite/src/types/payments.ts | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/satellite/payments/balance.go b/satellite/payments/balance.go index 86c26b6ee..8bef2ae01 100644 --- a/satellite/payments/balance.go +++ b/satellite/payments/balance.go @@ -13,7 +13,7 @@ type Balance struct { FreeCredits int64 `json:"freeCredits"` Coins decimal.Decimal `json:"coins"` // STORJ token balance from storjscan. Credits decimal.Decimal `json:"credits"` - // Credits is the balance from stripe. This may include the following. + // Credits is the balance (in cents) from stripe. This may include the following. // 1. legacy Coinpayments deposit. // 2. legacy credit for a manual STORJ deposit. // 4. bonus manually credited for a storjscan payment once a month before invoicing. diff --git a/web/satellite/src/components/account/billing/billingTabs/Overview.vue b/web/satellite/src/components/account/billing/billingTabs/Overview.vue index 617a5f738..6019e4487 100644 --- a/web/satellite/src/components/account/billing/billingTabs/Overview.vue +++ b/web/satellite/src/components/account/billing/billingTabs/Overview.vue @@ -46,9 +46,9 @@

-
+
-

${{ balance.credits }}

+

{{ balance.formattedCredits }}

Legacy STORJ Payments and Bonuses

diff --git a/web/satellite/src/types/payments.ts b/web/satellite/src/types/payments.ts index 2bcafb42e..007e5d677 100644 --- a/web/satellite/src/types/payments.ts +++ b/web/satellite/src/types/payments.ts @@ -1,6 +1,8 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +import { formatPrice, decimalShift } from '@/utils/strings'; + /** * Exposes all payments-related functionality */ @@ -126,7 +128,7 @@ export class AccountBalance { public freeCredits: number = 0, // STORJ token balance from storjscan. private _coins: string = '0', - // STORJ balance from stripe. This may include the following. + // STORJ balance (in cents) from stripe. This may include the following. // 1. legacy Coinpayments deposit. // 2. legacy credit for a manual STORJ deposit. // 4. bonus manually credited for a storjscan payment once a month before invoicing. @@ -138,13 +140,17 @@ export class AccountBalance { return parseFloat(this._coins); } - public get credits(): number { - return parseFloat(this._credits); + public get formattedCredits(): string { + return formatPrice(decimalShift(this._credits, 2)); } public get sum(): number { return this.freeCredits + this.coins; } + + public hasCredits(): boolean { + return parseFloat(this._credits) !== 0; + } } export class CreditCard {