upgrade
This commit is contained in:
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user