adasd
This commit is contained in:
@@ -198,18 +198,43 @@
|
||||
}).format(Number(value));
|
||||
}
|
||||
|
||||
function deriveDailyCostAmount(totalCostAmount, runtimeMonths) {
|
||||
const amount = Number(totalCostAmount);
|
||||
function calendarRuntimeEnd(startAt, runtimeMonths) {
|
||||
const start = parseStoredUtcDate(startAt);
|
||||
const months = Number(runtimeMonths);
|
||||
if (!Number.isFinite(amount) || !Number.isFinite(months) || months <= 0) {
|
||||
if (!start || !Number.isInteger(months) || months <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const runtimeDays = months * 30.4375;
|
||||
if (!Number.isFinite(runtimeDays) || runtimeDays <= 0) {
|
||||
const targetMonthIndex = (start.getUTCFullYear() * 12) + start.getUTCMonth() + months;
|
||||
const targetYear = Math.floor(targetMonthIndex / 12);
|
||||
const targetMonth = targetMonthIndex % 12;
|
||||
const lastDayOfTargetMonth = new Date(Date.UTC(targetYear, targetMonth + 1, 0)).getUTCDate();
|
||||
return new Date(Date.UTC(
|
||||
targetYear,
|
||||
targetMonth,
|
||||
Math.min(start.getUTCDate(), lastDayOfTargetMonth),
|
||||
start.getUTCHours(),
|
||||
start.getUTCMinutes(),
|
||||
start.getUTCSeconds(),
|
||||
start.getUTCMilliseconds()
|
||||
));
|
||||
}
|
||||
|
||||
function runtimeDaysForEntry(startAt, runtimeMonths) {
|
||||
const start = parseStoredUtcDate(startAt);
|
||||
const end = calendarRuntimeEnd(startAt, runtimeMonths);
|
||||
if (!start || !end) {
|
||||
return null;
|
||||
}
|
||||
return (end.getTime() - start.getTime()) / 86400000;
|
||||
}
|
||||
|
||||
function deriveDailyCostAmount(totalCostAmount, runtimeMonths, startsAt) {
|
||||
const amount = Number(totalCostAmount);
|
||||
const runtimeDays = runtimeDaysForEntry(startsAt, runtimeMonths);
|
||||
if (!Number.isFinite(amount) || !Number.isFinite(runtimeDays) || runtimeDays <= 0) {
|
||||
return null;
|
||||
}
|
||||
return amount / runtimeDays;
|
||||
}
|
||||
|
||||
@@ -356,8 +381,10 @@
|
||||
return { endAt: null, isCovered: true };
|
||||
}
|
||||
|
||||
const runtimeMs = normalizedRuntime * 30.4375 * 86400 * 1000;
|
||||
const endAtDate = new Date(startDate.getTime() + runtimeMs);
|
||||
const endAtDate = calendarRuntimeEnd(startAt, normalizedRuntime);
|
||||
if (!endAtDate) {
|
||||
return { endAt: null, isCovered: true };
|
||||
}
|
||||
return {
|
||||
endAt: endAtDate.toISOString(),
|
||||
isCovered: !!autoRenew || Date.now() <= endAtDate.getTime(),
|
||||
@@ -582,6 +609,7 @@
|
||||
current_effective_coins: null,
|
||||
wallet_balances: {},
|
||||
wallet_balance_current_asset: null,
|
||||
wallet_balance_current_asset_direct: null,
|
||||
holdings_current_asset: null,
|
||||
},
|
||||
current_hashrate_mh: null,
|
||||
@@ -1438,10 +1466,7 @@
|
||||
baseAmount = fallbackUsdReference;
|
||||
baseCurrency = 'USD';
|
||||
}
|
||||
const storedDailyAmount = Number(miner.daily_cost_amount);
|
||||
const dailyAmount = Number.isFinite(storedDailyAmount) && storedDailyAmount > 0
|
||||
? storedDailyAmount
|
||||
: deriveDailyCostAmount(miner.total_cost_amount, miner.runtime_months);
|
||||
const dailyAmount = deriveDailyCostAmount(miner.total_cost_amount, miner.runtime_months, miner.purchased_at);
|
||||
const dailyCurrency = String(miner.daily_cost_currency || miner.currency || '').toUpperCase();
|
||||
const dailyReportAmount = Number.isFinite(dailyAmount) && dailyCurrency
|
||||
? (dailyCurrency === reportCurrency ? dailyAmount : convertCurrencyValue(dailyAmount, dailyCurrency, reportCurrency))
|
||||
@@ -1450,7 +1475,7 @@
|
||||
const settledAmount = Number(miner.settled_value_amount);
|
||||
const settledCurrency = String(miner.settled_value_currency || '').toUpperCase();
|
||||
const hasHistoricalSettlement = Number.isFinite(settledAmount) && settledAmount > 0 && settledCurrency;
|
||||
const runtimeDays = Number(miner.runtime_months) * 30.4375;
|
||||
const runtimeDays = runtimeDaysForEntry(miner.purchased_at, miner.runtime_months);
|
||||
const costPerKhAmount = totalHashrateKh > 0 && Number.isFinite(runtimeDays) && runtimeDays > 0
|
||||
? ((paymentType === 'crypto' && hasHistoricalSettlement ? settledAmount : Number(miner.total_cost_amount)) / totalHashrateKh / runtimeDays)
|
||||
: null;
|
||||
@@ -1489,16 +1514,13 @@
|
||||
};
|
||||
}).concat(currentCostPlans.map((plan) => {
|
||||
const coverage = entryCoverageMeta(plan.starts_at, plan.runtime_months, plan.auto_renew);
|
||||
const storedDailyAmount = Number(plan.daily_cost_amount);
|
||||
const dailyAmount = Number.isFinite(storedDailyAmount) && storedDailyAmount > 0
|
||||
? storedDailyAmount
|
||||
: deriveDailyCostAmount(plan.total_cost_amount, plan.runtime_months);
|
||||
const dailyAmount = deriveDailyCostAmount(plan.total_cost_amount, plan.runtime_months, plan.starts_at);
|
||||
const dailyCurrency = String(plan.daily_cost_currency || plan.currency || '').toUpperCase();
|
||||
const dailyReportAmount = Number.isFinite(dailyAmount) && dailyCurrency
|
||||
? (dailyCurrency === reportCurrency ? dailyAmount : convertCurrencyValue(dailyAmount, dailyCurrency, reportCurrency))
|
||||
: null;
|
||||
const totalHashrateKh = toKhPerSecond(plan.mining_speed_value, plan.mining_speed_unit) + toKhPerSecond(plan.bonus_speed_value, plan.bonus_speed_unit);
|
||||
const runtimeDays = Number(plan.runtime_months) * 30.4375;
|
||||
const runtimeDays = runtimeDaysForEntry(plan.starts_at, plan.runtime_months);
|
||||
const costPerKhAmount = totalHashrateKh > 0 && Number.isFinite(runtimeDays) && runtimeDays > 0
|
||||
? Number(plan.total_cost_amount) / totalHashrateKh / runtimeDays
|
||||
: null;
|
||||
@@ -3206,12 +3228,11 @@
|
||||
const perDayLabel = `${currentCoinCurrency} pro Tag`;
|
||||
|
||||
if (activeTab === 'overview') {
|
||||
const latestValue = latest ? convertMeasurementMoney(latest, latest.current_value, reportCurrency) : null;
|
||||
const latestPriceSource = latest && latest.effective_price_per_coin !== null && latest.effective_price_per_coin !== undefined
|
||||
? latest.effective_price_per_coin
|
||||
: (latest ? latest.price_per_coin : null);
|
||||
const latestPrice = latest && latestPriceSource !== null && latestPriceSource !== undefined
|
||||
? convertMeasurementMoney(latest, latestPriceSource, reportCurrency)
|
||||
const latestCoinPriceUsd = latest && latestPriceSource !== null && latestPriceSource !== undefined
|
||||
? convertMeasurementMoney(latest, latestPriceSource, 'USD')
|
||||
: null;
|
||||
const dailyRevenue = latest ? convertMeasurementMoney(latest, latest.theoretical_daily_revenue, reportCurrency) : null;
|
||||
const dailyProfit = latest ? convertMeasurementMoney(latest, latest.theoretical_daily_profit, reportCurrency) : null;
|
||||
@@ -3225,7 +3246,6 @@
|
||||
: null;
|
||||
const investedCapital = latest ? convertMeasurementMoney(latest, latest.cash_invested_capital ?? latest.invested_capital, reportCurrency) : null;
|
||||
const reinvestedCapital = latest ? convertMeasurementMoney(latest, latest.reinvested_capital, reportCurrency) : null;
|
||||
const walletValue = latest ? convertMeasurementMoney(latest, latest.wallet_value, reportCurrency) : null;
|
||||
const totalHoldingsValue = latest ? convertMeasurementMoney(latest, latest.total_holdings_value, reportCurrency) : null;
|
||||
const earnedValue = latest ? convertMeasurementMoney(latest, latest.earned_value, reportCurrency) : null;
|
||||
const settledCryptoSpendValue = latest ? convertMeasurementMoney(latest, latest.settled_crypto_spend_value, reportCurrency) : null;
|
||||
@@ -3238,10 +3258,14 @@
|
||||
: null;
|
||||
const breakEvenReached = breakEvenRemainingAmount !== null && breakEvenRemainingAmount <= 0;
|
||||
const breakEvenEta = latest && latest.break_even_eta_at ? fmtDate(latest.break_even_eta_at) : null;
|
||||
const walletBalanceCurrentAsset = payload?.summary?.payouts?.wallet_balance_current_asset;
|
||||
const walletBalanceCurrentAssetDirect = payload?.summary?.payouts?.wallet_balance_current_asset_direct;
|
||||
const holdingsCurrentAsset = payload?.summary?.payouts?.holdings_current_asset;
|
||||
const minerVisibleCoins = latest ? Number(latest.coins_total_visible ?? latest.coins_total) : null;
|
||||
const walletCurrentAssetCoins = walletBalanceCurrentAssetDirect !== null && walletBalanceCurrentAssetDirect !== undefined
|
||||
? Number(walletBalanceCurrentAssetDirect)
|
||||
: null;
|
||||
const totalCurrentAssetCoins = Number.isFinite(walletCurrentAssetCoins) && Number.isFinite(minerVisibleCoins)
|
||||
? walletCurrentAssetCoins + minerVisibleCoins
|
||||
: null;
|
||||
const minerVisibleValue = latest && latest.current_value !== null && latest.current_value !== undefined
|
||||
? Number(latest.current_value)
|
||||
: (
|
||||
@@ -3322,20 +3346,21 @@
|
||||
: 'Noch kein Transfer vor dem letzten Upload',
|
||||
}),
|
||||
h(StatCard, {
|
||||
key: 'value',
|
||||
label: 'Bisheriger Wert',
|
||||
value: earnedValue !== null ? fmtMoney(earnedValue, reportCurrency) : 'n/a',
|
||||
key: 'current-asset-balance',
|
||||
label: `${currentCoinCurrency} Bestand`,
|
||||
value: totalCurrentAssetCoins !== null ? `${fmtNumber(totalCurrentAssetCoins, 6)} ${currentCoinCurrency}` : 'n/a',
|
||||
sub: [
|
||||
holdingsCurrentAsset !== null && holdingsCurrentAsset !== undefined
|
||||
? `Variabel ${fmtNumber(holdingsCurrentAsset, 6)} ${currentCoinCurrency}`
|
||||
walletCurrentAssetCoins !== null && Number.isFinite(walletCurrentAssetCoins)
|
||||
? `Wallet ${fmtNumber(walletCurrentAssetCoins, 6)} ${currentCoinCurrency}`
|
||||
: null,
|
||||
latestValue !== null ? `Miner ${fmtMoney(latestValue, reportCurrency)}` : null,
|
||||
walletValue !== null ? `Wallet ${fmtMoney(walletValue, reportCurrency)}` : null,
|
||||
settledCryptoSpendValue !== null ? `Fix ausgegeben ${fmtMoney(settledCryptoSpendValue, reportCurrency)}` : null,
|
||||
latestPrice !== null
|
||||
? `Kurs ${fmtNumber(latestPrice, 6)} ${reportCurrency}${latest && latest.price_is_fallback ? ' · Fallback aus letztem Kurs' : ''}`
|
||||
Number.isFinite(minerVisibleCoins)
|
||||
? `Miner ${fmtNumber(minerVisibleCoins, 6)} ${currentCoinCurrency}`
|
||||
: null,
|
||||
].filter(Boolean).join(' · ') || 'Kein umrechenbarer Kurs am letzten Punkt',
|
||||
totalCurrentAssetCoins !== null ? `Gesamt ${fmtNumber(totalCurrentAssetCoins, 6)} ${currentCoinCurrency}` : null,
|
||||
latestCoinPriceUsd !== null
|
||||
? `Letzter ${currentCoinCurrency}-Kurs ${fmtNumber(latestCoinPriceUsd, 6)} USD${latest && latest.price_is_fallback ? ' · Fallback aus letztem Kurs' : ''}`
|
||||
: null,
|
||||
].filter(Boolean).join(' · ') || 'Kein Wallet- oder Mining-Bestand vorhanden',
|
||||
}),
|
||||
h(StatCard, {
|
||||
key: 'preferred-offer-target',
|
||||
|
||||
Reference in New Issue
Block a user