satellite/{web,payments}: display correct stripe balance

This correctly displays the stripe balance in dollars, which was
previously displayed in cents.

Change-Id: Ifb14a63a90d3701201c616780cee466525c8be18
This commit is contained in:
Wilfred Asomani 2023-03-17 14:37:28 +00:00 committed by Jeremy Wharton
parent e0c3f66040
commit bf45e53169
3 changed files with 12 additions and 6 deletions

View File

@ -13,7 +13,7 @@ type Balance struct {
FreeCredits int64 `json:"freeCredits"` FreeCredits int64 `json:"freeCredits"`
Coins decimal.Decimal `json:"coins"` // STORJ token balance from storjscan. Coins decimal.Decimal `json:"coins"` // STORJ token balance from storjscan.
Credits decimal.Decimal `json:"credits"` 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. // 1. legacy Coinpayments deposit.
// 2. legacy credit for a manual STORJ deposit. // 2. legacy credit for a manual STORJ deposit.
// 4. bonus manually credited for a storjscan payment once a month before invoicing. // 4. bonus manually credited for a storjscan payment once a month before invoicing.

View File

@ -46,9 +46,9 @@
</p> </p>
</div> </div>
<div v-if="balance.credits" class="total-cost__card"> <div v-if="balance.hasCredits()" class="total-cost__card">
<AvailableBalanceIcon class="total-cost__card__main-icon" /> <AvailableBalanceIcon class="total-cost__card__main-icon" />
<p class="total-cost__card__money-text">${{ balance.credits }}</p> <p class="total-cost__card__money-text">{{ balance.formattedCredits }}</p>
<p class="total-cost__card__label-text">Legacy STORJ Payments and Bonuses</p> <p class="total-cost__card__label-text">Legacy STORJ Payments and Bonuses</p>
</div> </div>
</div> </div>

View File

@ -1,6 +1,8 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
import { formatPrice, decimalShift } from '@/utils/strings';
/** /**
* Exposes all payments-related functionality * Exposes all payments-related functionality
*/ */
@ -126,7 +128,7 @@ export class AccountBalance {
public freeCredits: number = 0, public freeCredits: number = 0,
// STORJ token balance from storjscan. // STORJ token balance from storjscan.
private _coins: string = '0', 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. // 1. legacy Coinpayments deposit.
// 2. legacy credit for a manual STORJ deposit. // 2. legacy credit for a manual STORJ deposit.
// 4. bonus manually credited for a storjscan payment once a month before invoicing. // 4. bonus manually credited for a storjscan payment once a month before invoicing.
@ -138,13 +140,17 @@ export class AccountBalance {
return parseFloat(this._coins); return parseFloat(this._coins);
} }
public get credits(): number { public get formattedCredits(): string {
return parseFloat(this._credits); return formatPrice(decimalShift(this._credits, 2));
} }
public get sum(): number { public get sum(): number {
return this.freeCredits + this.coins; return this.freeCredits + this.coins;
} }
public hasCredits(): boolean {
return parseFloat(this._credits) !== 0;
}
} }
export class CreditCard { export class CreditCard {