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

This commit is contained in:
2026-05-09 01:15:05 +02:00
parent fc95898a9d
commit 693086029d
2 changed files with 55 additions and 8 deletions

View File

@@ -1891,7 +1891,12 @@
: 'n/a'), : 'n/a'),
displayField('Erkannte Wallet-Assets', Object.entries(preview.suggested_wallet.balances_json || {}) displayField('Erkannte Wallet-Assets', Object.entries(preview.suggested_wallet.balances_json || {})
.slice(0, 8) .slice(0, 8)
.map(([code, amount]) => `${fmtNumber(amount, 8)} ${code}`) .map(([code, asset]) => {
const balance = asset && typeof asset === 'object' ? asset.balance : asset;
const priceAmount = asset && typeof asset === 'object' ? asset.price_amount : null;
const priceCurrency = asset && typeof asset === 'object' ? asset.price_currency : null;
return `${fmtNumber(balance, 8)} ${code}${priceAmount ? ` @ ${fmtNumber(priceAmount, 6)} ${priceCurrency || ''}`.trim() : ''}`;
})
.join(' · ') || 'n/a'), .join(' · ') || 'n/a'),
]) ])
: h('div', { key: 'measurement-form', className: 'mc-two-col' }, [ : h('div', { key: 'measurement-form', className: 'mc-two-col' }, [
@@ -2197,7 +2202,12 @@
h('td', { key: 'balance' }, row.wallet_balance !== null && row.wallet_balance !== undefined ? `${fmtNumber(row.wallet_balance, 8)} ${row.wallet_currency || ''}`.trim() : 'n/a'), h('td', { key: 'balance' }, row.wallet_balance !== null && row.wallet_balance !== undefined ? `${fmtNumber(row.wallet_balance, 8)} ${row.wallet_currency || ''}`.trim() : 'n/a'),
h('td', { key: 'value' }, row.total_value_amount !== null && row.total_value_amount !== undefined ? `${fmtNumber(row.total_value_amount, 4)} ${row.total_value_currency || ''}`.trim() : 'n/a'), h('td', { key: 'value' }, row.total_value_amount !== null && row.total_value_amount !== undefined ? `${fmtNumber(row.total_value_amount, 4)} ${row.total_value_currency || ''}`.trim() : 'n/a'),
h('td', { key: 'source' }, row.source || 'manual'), h('td', { key: 'source' }, row.source || 'manual'),
h('td', { key: 'assets' }, Object.entries(row.balances_json || {}).slice(0, 6).map(([code, amount]) => `${fmtNumber(amount, 8)} ${code}`).join(' · ') || 'n/a'), h('td', { key: 'assets' }, Object.entries(row.balances_json || {}).slice(0, 6).map(([code, asset]) => {
const balance = asset && typeof asset === 'object' ? asset.balance : asset;
const priceAmount = asset && typeof asset === 'object' ? asset.price_amount : null;
const priceCurrency = asset && typeof asset === 'object' ? asset.price_currency : null;
return `${fmtNumber(balance, 8)} ${code}${priceAmount ? ` @ ${fmtNumber(priceAmount, 6)} ${priceCurrency || ''}`.trim() : ''}`;
}).join(' · ') || 'n/a'),
])) ]))
: [h('tr', { key: 'empty' }, h('td', { colSpan: 6 }, 'Noch keine Wallet-Snapshots gespeichert.'))] : [h('tr', { key: 'empty' }, h('td', { colSpan: 6 }, 'Noch keine Wallet-Snapshots gespeichert.'))]
), ),

View File

@@ -491,26 +491,61 @@ final class OcrService
$flags[] = 'wallet_total_missing'; $flags[] = 'wallet_total_missing';
} }
preg_match_all(
'/([A-Z][A-Za-z0-9]+(?:\s+[A-Z][A-Za-z0-9]+)*)\s+(\d+(?:[.,]\d+)?)\s+([A-Z]{2,10})\s+(?:\d+(?:[.,]\d+)?)\s+USD\s+(\d+(?:[.,]\d+)?)\s+USD/u',
$normalizedText,
$assetRowMatches,
PREG_SET_ORDER
);
foreach ($assetRowMatches as $match) {
$balanceAmount = round((float) str_replace(',', '.', $match[2]), 10);
$assetCurrency = strtoupper((string) $match[3]);
$priceAmount = round((float) str_replace(',', '.', $match[4]), 8);
if ($balanceAmount <= 0 || $assetCurrency === '') {
continue;
}
$balances[$assetCurrency] = [
'balance' => $balanceAmount,
'price_amount' => $priceAmount > 0 ? $priceAmount : null,
'price_currency' => $priceAmount > 0 ? 'USD' : null,
];
}
preg_match_all('/(\d+(?:[.,]\d+)?)\s*([A-Z]{2,10})\b/u', $normalizedText, $balanceMatches, PREG_SET_ORDER); preg_match_all('/(\d+(?:[.,]\d+)?)\s*([A-Z]{2,10})\b/u', $normalizedText, $balanceMatches, PREG_SET_ORDER);
foreach ($balanceMatches as $match) { foreach ($balanceMatches as $match) {
$amount = round((float) str_replace(',', '.', $match[1]), 10); $amount = round((float) str_replace(',', '.', $match[1]), 10);
$currency = strtoupper((string) $match[2]); $currency = strtoupper((string) $match[2]);
if ($amount <= 0 || $currency === '') { if ($amount <= 0 || $currency === '' || in_array($currency, ['USD', 'EUR'], true)) {
continue; continue;
} }
if (!isset($balances[$currency]) || $amount > (float) $balances[$currency]) { if (!isset($balances[$currency])) {
$balances[$currency] = $amount; $balances[$currency] = [
'balance' => $amount,
'price_amount' => null,
'price_currency' => null,
];
continue;
}
$existingBalance = is_array($balances[$currency]) ? (float) ($balances[$currency]['balance'] ?? 0.0) : (float) $balances[$currency];
if ($amount > $existingBalance) {
$balances[$currency]['balance'] = $amount;
} }
} }
if ($walletCurrencyHint !== '' && array_key_exists($walletCurrencyHint, $balances)) { if ($walletCurrencyHint !== '' && array_key_exists($walletCurrencyHint, $balances)) {
$walletCurrency = $walletCurrencyHint; $walletCurrency = $walletCurrencyHint;
$walletBalance = (float) $balances[$walletCurrencyHint]; $walletBalance = is_array($balances[$walletCurrencyHint])
? (float) ($balances[$walletCurrencyHint]['balance'] ?? 0.0)
: (float) $balances[$walletCurrencyHint];
} elseif ($balances !== []) { } elseif ($balances !== []) {
foreach (['DOGE', 'BTC', 'ETH', 'CTC', 'HSH', 'LTC', 'USDT', 'USDC'] as $preferredCurrency) { foreach (['DOGE', 'BTC', 'ETH', 'CTC', 'HSH', 'LTC', 'USDT', 'USDC'] as $preferredCurrency) {
if (array_key_exists($preferredCurrency, $balances)) { if (array_key_exists($preferredCurrency, $balances)) {
$walletCurrency = $preferredCurrency; $walletCurrency = $preferredCurrency;
$walletBalance = (float) $balances[$preferredCurrency]; $walletBalance = is_array($balances[$preferredCurrency])
? (float) ($balances[$preferredCurrency]['balance'] ?? 0.0)
: (float) $balances[$preferredCurrency];
break; break;
} }
} }
@@ -518,7 +553,9 @@ final class OcrService
$firstCurrency = array_key_first($balances); $firstCurrency = array_key_first($balances);
if (is_string($firstCurrency)) { if (is_string($firstCurrency)) {
$walletCurrency = $firstCurrency; $walletCurrency = $firstCurrency;
$walletBalance = (float) $balances[$firstCurrency]; $walletBalance = is_array($balances[$firstCurrency])
? (float) ($balances[$firstCurrency]['balance'] ?? 0.0)
: (float) $balances[$firstCurrency];
} }
} }
} else { } else {