Update
All checks were successful
Deploy / deploy-staging (push) Successful in 26s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-08-14 02:03:17 +02:00
parent 3d2b566bf2
commit 3205d9f0f6
6 changed files with 470 additions and 42 deletions

View File

@@ -189,6 +189,21 @@
}).format(Number(value));
}
function deriveDailyCostAmount(totalCostAmount, runtimeMonths) {
const amount = Number(totalCostAmount);
const months = Number(runtimeMonths);
if (!Number.isFinite(amount) || !Number.isFinite(months) || months <= 0) {
return null;
}
const runtimeDays = months * 30.4375;
if (!Number.isFinite(runtimeDays) || runtimeDays <= 0) {
return null;
}
return amount / runtimeDays;
}
function recentMeasurementWindow(rows, windowDays) {
if (!Array.isArray(rows) || rows.length === 0) {
return [];
@@ -544,8 +559,10 @@
}
function normalizeSchemaStatus(data) {
const normalized = data && typeof data === 'object' ? data : {};
const hasPayload = !!(data && typeof data === 'object');
const normalized = hasPayload ? data : {};
return {
loaded: hasPayload,
required_tables: Array.isArray(normalized.required_tables) ? normalized.required_tables : [],
present_tables: Array.isArray(normalized.present_tables) ? normalized.present_tables : [],
missing_tables: Array.isArray(normalized.missing_tables) ? normalized.missing_tables : [],
@@ -1275,6 +1292,14 @@
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 dailyCurrency = String(miner.daily_cost_currency || miner.currency || '').toUpperCase();
const dailyReportAmount = Number.isFinite(dailyAmount) && dailyCurrency
? (dailyCurrency === reportCurrency ? dailyAmount : convertCurrencyValue(dailyAmount, dailyCurrency, reportCurrency))
: null;
return {
id: `purchase-${miner.id}`,
source: 'miete',
@@ -1284,6 +1309,9 @@
auto_renew: effectiveAutoRenew,
effective_amount: miner.total_cost_amount,
effective_currency: miner.currency,
daily_cost_amount: dailyAmount,
daily_cost_currency: dailyCurrency,
daily_cost_report_amount: Number.isFinite(dailyReportAmount) ? dailyReportAmount : null,
base_amount: baseAmount,
base_currency: baseCurrency,
miner_id: miner.id,
@@ -1299,6 +1327,14 @@
};
}).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 dailyCurrency = String(plan.daily_cost_currency || plan.currency || '').toUpperCase();
const dailyReportAmount = Number.isFinite(dailyAmount) && dailyCurrency
? (dailyCurrency === reportCurrency ? dailyAmount : convertCurrencyValue(dailyAmount, dailyCurrency, reportCurrency))
: null;
return {
id: `plan-${plan.id}`,
source: 'manual',
@@ -1308,6 +1344,9 @@
auto_renew: !!plan.auto_renew,
effective_amount: plan.total_cost_amount,
effective_currency: plan.currency,
daily_cost_amount: dailyAmount,
daily_cost_currency: dailyCurrency,
daily_cost_report_amount: Number.isFinite(dailyReportAmount) ? dailyReportAmount : null,
base_amount: plan.base_price_amount,
base_currency: currentSettings.report_currency || 'EUR',
payment_type: plan.payment_type,
@@ -1642,6 +1681,7 @@
setSchemaStatus(normalizeSchemaStatus(schema));
} catch (err) {
setSchemaStatus(normalizeSchemaStatus(null));
setError((previous) => previous || `Schema-Status konnte nicht geladen werden: ${err.message}`);
}
}
@@ -2984,6 +3024,13 @@
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 minerValueUsd = latest && minerVisibleCoins !== null
? convertMeasurementMoney(latest, minerVisibleCoins, 'USD')
: null;
const minerValueReport = latest && minerVisibleCoins !== null
? convertMeasurementMoney(latest, minerVisibleCoins, reportCurrency)
: null;
return h('div', { className: 'mc-stack' }, [
panel('Berichtswährung', 'Bestimmt die Währung für Kennzahlen im Überblick. Standard kommt aus den Settings, diese Auswahl gilt nur für den aktuellen Besuch.', [
@@ -3006,8 +3053,12 @@
h(StatCard, {
key: 'coins',
label: `${currentCoinCurrency} im Miner`,
value: latest ? fmtNumber(latest.coins_total_visible ?? latest.coins_total, 6) : 'n/a',
sub: latest ? `Stand ${fmtDate(latest.measured_at)}` : '',
value: latest ? fmtNumber(minerVisibleCoins, 6) : 'n/a',
sub: latest ? [
minerValueUsd !== null ? `USD ${fmtMoney(minerValueUsd, 'USD')}` : null,
reportCurrency !== 'USD' && minerValueReport !== null ? `${reportCurrency} ${fmtMoney(minerValueReport, reportCurrency)}` : null,
`Stand ${fmtDate(latest.measured_at)}`,
].filter(Boolean).join(' · ') : '',
}),
h(StatCard, {
key: 'earned-overall',
@@ -3434,6 +3485,14 @@
h('td', { key: 'renew' }, row.payment_type === 'crypto' ? 'nein' : (row.auto_renew ? 'ja' : 'nein')),
h('td', { key: 'cost' }, [
h('div', { key: 'effective' }, fmtNumber(row.effective_amount, 6)),
row.daily_cost_amount !== null && row.daily_cost_amount !== undefined && row.daily_cost_currency
? h('div', { key: 'daily', className: 'mc-kicker' }, [
`Pro Tag ${fmtNumber(row.daily_cost_amount, 6)} ${row.daily_cost_currency}`,
row.daily_cost_report_amount !== null && row.daily_cost_report_amount !== undefined && row.daily_cost_currency !== reportCurrency
? ` · ${fmtMoney(row.daily_cost_report_amount, reportCurrency)}`
: '',
].join(''))
: null,
row.base_amount !== null && row.base_amount !== undefined && row.base_currency
? h('div', { key: 'base', className: 'mc-kicker' }, `Basis ${fmtNumber(row.base_amount, 6)} ${row.base_currency}`)
: null,
@@ -3576,12 +3635,24 @@
offer.crypto_display_price_amount !== null && offer.crypto_display_price_currency
? h('div', { key: 'price-crypto' }, [
h('div', { key: 'amount' }, `${fmtNumber(offer.crypto_display_price_amount, 6)} ${offer.crypto_display_price_currency}`),
(() => {
const offerDailyAmount = deriveDailyCostAmount(offer.crypto_display_price_amount, offer.runtime_months);
return offerDailyAmount !== null
? h('div', { key: 'daily', className: 'mc-kicker' }, `Pro Tag ${fmtNumber(offerDailyAmount, 6)} ${offer.crypto_display_price_currency}`)
: null;
})(),
h('div', { key: 'label', className: 'mc-kicker' }, 'Zu zahlen in Krypto'),
])
: null,
offer.usd_display_price_amount !== null && offer.usd_display_price_currency
? h('div', { key: 'price-usd' }, [
h('div', { key: 'amount' }, `${fmtNumber(offer.usd_display_price_amount, 6)} ${offer.usd_display_price_currency}`),
(() => {
const offerDailyAmount = deriveDailyCostAmount(offer.usd_display_price_amount, offer.runtime_months);
return offerDailyAmount !== null
? h('div', { key: 'daily', className: 'mc-kicker' }, `Pro Tag ${fmtNumber(offerDailyAmount, 6)} ${offer.usd_display_price_currency}`)
: null;
})(),
h('div', { key: 'label', className: 'mc-kicker' }, 'Zu zahlen in USD'),
])
: null,
@@ -3589,6 +3660,12 @@
: [
h('div', { key: 'price-main' }, [
h('div', { key: 'amount' }, `${fmtNumber(offer.effective_price_amount, 6)} ${offer.effective_price_currency}`),
(() => {
const offerDailyAmount = deriveDailyCostAmount(offer.effective_price_amount, offer.runtime_months);
return offerDailyAmount !== null
? h('div', { key: 'daily', className: 'mc-kicker' }, `Pro Tag ${fmtNumber(offerDailyAmount, 6)} ${offer.effective_price_currency}`)
: null;
})(),
h('div', { key: 'label', className: 'mc-kicker' }, 'Zu zahlen'),
]),
offer.base_price_amount !== null && offer.base_price_currency
@@ -3892,10 +3969,10 @@
h('div', { className: 'mc-stack' }, [
panel('Initialisierung', 'Prueft den Tabellenstatus und kann das Mining-Checker Schema neu anlegen. Reset loescht bestehende miningcheck_ Tabellen inklusive Daten.', [
h('div', { key: 'status', className: 'mc-form' }, [
displayField('Status', schemaStatus.all_present ? 'Schema vollstaendig vorhanden' : 'Schema unvollstaendig'),
displayField('Vorhandene Tabellen', `${schemaStatus.present_count}/${schemaStatus.required_tables.length}`),
displayField('Fehlende Tabellen', schemaStatus.missing_tables.length ? schemaStatus.missing_tables.join(', ') : 'keine'),
displayField('Ausstehende Upgrades', schemaStatus.pending_upgrades.length ? schemaStatus.pending_upgrades.join(', ') : 'keine'),
displayField('Status', !schemaStatus.loaded ? 'Status unbekannt' : (schemaStatus.all_present ? 'Schema vollstaendig vorhanden' : 'Schema unvollstaendig')),
displayField('Vorhandene Tabellen', schemaStatus.loaded ? `${schemaStatus.present_count}/${schemaStatus.required_tables.length}` : 'Status konnte nicht geladen werden'),
displayField('Fehlende Tabellen', schemaStatus.loaded ? (schemaStatus.missing_tables.length ? schemaStatus.missing_tables.join(', ') : 'keine') : 'Status konnte nicht geladen werden'),
displayField('Ausstehende Upgrades', schemaStatus.loaded ? (schemaStatus.pending_upgrades.length ? schemaStatus.pending_upgrades.join(', ') : 'keine') : 'Status konnte nicht geladen werden'),
]),
h('form', { key: 'form', className: 'mc-form', onSubmit: initializeModule }, [
h('label', { className: 'mc-checkbox' }, [