web/storagenode: gross total added to historical data, with surge moved

WHAT:
changed estimation table row order.

WHY:
to show gross total for selected period to avoid misunderstanding
when held amount is bigger than paid multiple times.

Change-Id: I03881c8af682372139a378030acf04f199d3260b
This commit is contained in:
NickolaiYurchenko 2020-09-04 15:05:13 +03:00
parent 205c39d404
commit 7c275830a1
5 changed files with 60 additions and 39 deletions

View File

@ -21,7 +21,7 @@ type PayoutMonthly struct {
EgressRepairAuditPayout float64 `json:"egressRepairAuditPayout"`
DiskSpace float64 `json:"diskSpace"`
DiskSpacePayout float64 `json:"diskSpacePayout"`
HeldRate int64 `json:"heldRate"`
HeldRate float64 `json:"heldRate"`
Payout float64 `json:"payout"`
Held float64 `json:"held"`
}
@ -46,7 +46,7 @@ func (pm *PayoutMonthly) SetDiskSpacePayout(diskSpacePrice int64) {
// SetHeldAmount counts held amount for PayoutMonthly object.
func (pm *PayoutMonthly) SetHeldAmount() {
amount := (pm.DiskSpacePayout + pm.EgressBandwidthPayout + pm.EgressRepairAuditPayout) * float64(pm.HeldRate/100)
amount := (pm.DiskSpacePayout + pm.EgressBandwidthPayout + pm.EgressRepairAuditPayout) * pm.HeldRate / 100
pm.Held = RoundFloat(amount)
}

View File

@ -95,19 +95,19 @@ type SatelliteHeldHistory struct {
// SatellitePayoutForPeriod contains payout information for specific period for specific satellite.
type SatellitePayoutForPeriod struct {
SatelliteID string `json:"satelliteID"`
SatelliteURL string `json:"satelliteURL"`
Age int64 `json:"age"`
Earned int64 `json:"earned"`
Surge int64 `json:"surge"`
SurgePercent int64 `json:"surgePercent"`
Held int64 `json:"held"`
HeldPercent int64 `json:"heldPercent"`
AfterHeld int64 `json:"afterHeld"`
Disposed int64 `json:"disposed"`
Paid int64 `json:"paid"`
Receipt string `json:"receipt"`
IsExitComplete bool `json:"isExitComplete"`
SatelliteID string `json:"satelliteID"`
SatelliteURL string `json:"satelliteURL"`
Age int64 `json:"age"`
Earned int64 `json:"earned"`
Surge int64 `json:"surge"`
SurgePercent int64 `json:"surgePercent"`
Held int64 `json:"held"`
HeldPercent float64 `json:"heldPercent"`
AfterHeld int64 `json:"afterHeld"`
Disposed int64 `json:"disposed"`
Paid int64 `json:"paid"`
Receipt string `json:"receipt"`
IsExitComplete bool `json:"isExitComplete"`
}
// Period is a string that represents paystub period type in format yyyy-mm.

View File

@ -347,7 +347,7 @@ func parsePeriodRange(periodStart, periodEnd string) (periods []string, err erro
}
// GetHeldRate returns held rate for specific period from join date of node.
func GetHeldRate(joinTime time.Time, requestTime time.Time) (heldRate int64) {
func GetHeldRate(joinTime time.Time, requestTime time.Time) (heldRate float64) {
monthsSinceJoin := date.MonthsBetweenDates(joinTime, requestTime)
switch monthsSinceJoin {
case 0, 1, 2:

View File

@ -68,7 +68,7 @@
<p class="estimation-table-container__info-area__text">{{ item.payout | centsToDollars }}</p>
</div>
</div>
<div class="estimation-table-container__info-area" v-if="isCurrentPeriod || isLastPeriodWithoutPaystub">
<div class="estimation-table-container__info-area">
<div class="column justify-start column-1">
<p class="estimation-table-container__info-area__text">Gross Total</p>
</div>
@ -80,11 +80,15 @@
<p class="estimation-table-container__info-area__text">{{ grossTotal | centsToDollars }}</p>
</div>
</div>
<div class="estimation-table-container__total-area" v-if="isHistoricalPeriod && totalPaystubForPeriod.surgePercent">
<p class="estimation-table-container__total-area__text">Total + Surge {{ surgePercent }}</p>
<p class="estimation-table-container__total-area__text">{{ totalPaystubForPeriod.paid | centsToDollars }}</p>
</div>
<div class="estimation-table-container__held-area">
<p class="estimation-table-container__held-area__text">Held Back</p>
<p class="estimation-table-container__held-area__text">-{{ held | centsToDollars }}</p>
</div>
<div class="estimation-table-container__held-area" v-if="!isCurrentPeriod && disposed > 0">
<div class="estimation-table-container__held-area" v-if="isHistoricalPeriod && disposed > 0">
<p class="estimation-table-container__held-area__text">Held returned</p>
<p class="estimation-table-container__held-area__text">{{ disposed | centsToDollars }}</p>
</div>
@ -104,10 +108,6 @@
<p class="estimation-table-container__net-total-area__text">{{ totalPayout | centsToDollars }}</p>
</div>
</div>
<div class="estimation-table-container__total-area" v-if="!isCurrentPeriod && !isLastPeriodWithoutPaystub && totalPaystubForPeriod.surgePercent">
<p class="estimation-table-container__total-area__text">Total + Surge {{ surgePercent }}</p>
<p class="estimation-table-container__total-area__text">{{ totalPaystubForPeriod.paid | centsToDollars }}</p>
</div>
</div>
<div class="no-data-container" v-else>
<img class="no-data-container__image" src="@/../static/images/payments/NoData.png">
@ -239,11 +239,11 @@ export default class EstimationArea extends Vue {
* Returns calculated or stored held amount.
*/
public get held(): number {
if (!this.isCurrentPeriod && !this.isLastPeriodWithoutPaystub) {
if (this.isHistoricalPeriod) {
return this.totalPaystubForPeriod.held;
}
return this.estimatedHeld();
return this.estimatedHeld;
}
/**
@ -253,21 +253,32 @@ export default class EstimationArea extends Vue {
return this.totalPaystubForPeriod.disposed;
}
/**
* Indicates if historical period with paystub selected.
*/
public get isHistoricalPeriod(): boolean {
return !this.isCurrentPeriod && !this.isLastPeriodWithoutPaystub;
}
/**
* Returns calculated or stored total payout by selected period.
*/
public get totalPayout(): number {
if (!this.isCurrentPeriod && !this.isLastPeriodWithoutPaystub) {
if (this.isHistoricalPeriod) {
return this.totalPaystubForPeriod.paid;
}
return this.grossTotal;
return this.grossTotal - this.estimatedHeld;
}
/**
* Returns calculated gross payout by selected period.
*/
public get grossTotal(): number {
if (this.isHistoricalPeriod) {
return this.totalPaystubForPeriod.paidWithoutSurge;
}
return this.isLastPeriodWithoutPaystub ? this.estimation.previousMonth.payout + this.held : this.estimation.currentMonth.payout + this.held;
}
@ -275,24 +286,26 @@ export default class EstimationArea extends Vue {
* Returns calculated or stored total used disk space by selected period.
*/
public get totalDiskSpace(): string {
if (this.isCurrentPeriod || this.isLastPeriodWithoutPaystub) {
return formatBytes(this.currentDiskSpace);
if (this.isHistoricalPeriod) {
return formatBytes(this.totalPaystubForPeriod.usageAtRest);
}
return formatBytes(this.totalPaystubForPeriod.usageAtRest);
return formatBytes(this.currentDiskSpace);
}
/**
* Returns calculated or stored total used bandwidth by selected period.
*/
public get totalBandwidth(): string {
if (this.isCurrentPeriod || this.isLastPeriodWithoutPaystub) {
return formatBytes((this.currentBandwidthAuditAndRepair + this.currentBandwidthDownload));
if (this.isHistoricalPeriod) {
return formatBytes(
this.totalPaystubForPeriod.usageGet +
this.totalPaystubForPeriod.usageGetRepair +
this.totalPaystubForPeriod.usageGetAudit,
);
}
const bandwidthSum = this.totalPaystubForPeriod.usageGet + this.totalPaystubForPeriod.usageGetRepair + this.totalPaystubForPeriod.usageGetAudit;
return formatBytes(bandwidthSum);
return formatBytes((this.currentBandwidthAuditAndRepair + this.currentBandwidthDownload));
}
/**
@ -320,7 +333,7 @@ export default class EstimationArea extends Vue {
* Builds estimated payout table depends on selected period.
*/
public get tableData(): EstimationTableRow[] {
if (!this.isCurrentPeriod && !this.isLastPeriodWithoutPaystub) {
if (this.isHistoricalPeriod) {
return [
new EstimationTableRow('Download', 'Egress', `$${BANDWIDTH_DOWNLOAD_PRICE_PER_TB / 100} / TB`, '--', formatBytes(this.totalPaystubForPeriod.usageGet), this.totalPaystubForPeriod.compGet),
new EstimationTableRow('Repair & Audit', 'Egress', `$${BANDWIDTH_REPAIR_PRICE_PER_TB / 100} / TB`, '--', formatBytes(this.totalPaystubForPeriod.usageGetRepair + this.totalPaystubForPeriod.usageGetAudit), this.totalPaystubForPeriod.compGetRepair + this.totalPaystubForPeriod.compGetAudit),
@ -376,7 +389,7 @@ export default class EstimationArea extends Vue {
/**
* Returns last or current month held amount based on current day of month.
*/
private estimatedHeld(): number {
private get estimatedHeld(): number {
return this.isLastPeriodWithoutPaystub ?
this.estimation.previousMonth.held :
this.estimation.currentMonth.held;
@ -562,10 +575,18 @@ export default class EstimationArea extends Vue {
}
}
&__net-total-area {
background-color: var(--estimation-table-total-container-color);
}
&__total-area {
align-items: center;
justify-content: space-between;
background-color: var(--estimation-table-total-container-color);
border-bottom: 1px solid #a9b5c1;
&__text {
font-family: 'font_regular', sans-serif;
}
}
}

View File

@ -156,8 +156,8 @@ export class TotalPaystubForPeriod {
this.owed += this.convertToCents(paystub.owed);
this.disposed += this.convertToCents(paystub.disposed);
this.paid += this.convertToCents(paystub.paid);
this.surgePercent = this.convertToCents(paystub.surgePercent);
this.paidWithoutSurge += this.convertToCents(paystub.paid) / paystub.surgeMultiplier;
this.surgePercent = paystub.surgePercent;
this.paidWithoutSurge += this.convertToCents(paystub.paid + paystub.held) / paystub.surgeMultiplier;
});
}