upgrade
All checks were successful
Deploy / deploy-staging (push) Successful in 1m6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-09-12 23:55:58 +02:00
parent d1d8e01fdc
commit 422331b32e
4 changed files with 29 additions and 10 deletions

View File

@@ -1475,8 +1475,10 @@ final class Router
$projectTimezone = $this->projectTimezone($projectKey);
$source = $this->enumValue($input['source'] ?? 'manual', ['manual', 'image_ocr', 'seed_import'], 'source');
$payload = [
'measured_at' => $source === 'seed_import'
? $this->requiredDateTime($input['measured_at'] ?? null, 'measured_at', $projectTimezone)
// A manual entry may document an older, verifiable upload. Only omit the
// timestamp when the user intentionally records the current state.
'measured_at' => trim((string) ($input['measured_at'] ?? '')) !== ''
? $this->requiredDateTime($input['measured_at'], 'measured_at', $projectTimezone)
: $this->currentTimestamp(),
'coins_total' => $this->requiredDecimal($input['coins_total'] ?? null, 'coins_total'),
'coin_currency' => $this->measurementCoinCurrency($projectKey, $input),
@@ -2861,18 +2863,21 @@ final class Router
}
if ($measuredAt !== '') {
$nearest = $this->fx()->nearestSnapshot('USD', $measuredAt, null, null);
// Never attach an unrelated current quote to a historical financial event.
$nearest = $this->fx()->nearestSnapshot('USD', $measuredAt, null, (int) round($maxAgeHours * 60));
if (is_array($nearest) && is_numeric($nearest['id'] ?? null)) {
return (int) $nearest['id'];
}
}
$latest = $this->fx()->latestSnapshot('USD', null);
if (is_array($latest) && is_numeric($latest['id'] ?? null)) {
return (int) $latest['id'];
if ($measuredAt === '' || $this->isRecentTimestamp($measuredAt, $maxAgeHours)) {
$latest = $this->fx()->latestSnapshot('USD', null);
if (is_array($latest) && is_numeric($latest['id'] ?? null)) {
return (int) $latest['id'];
}
}
if ($allowRefresh) {
if ($allowRefresh && ($measuredAt === '' || $this->isRecentTimestamp($measuredAt, $maxAgeHours))) {
$fresh = $this->fx()->refreshLatestRates(null, 'USD');
if (is_array($fresh) && is_numeric($fresh['fetch_id'] ?? null)) {
return (int) $fresh['fetch_id'];