Add a supplementary rate feed for currencies the ECB lacks (e.g. ALL)
The server also fetches ExchangeRate-API's free EUR-based endpoint (RATES_EXTRA_URL, empty = off), stored apart from ECB rates; ECB always wins for a currency both publish. /api/rates returns sources for supplementary rates, expenses record them as xr:<date>, and the editor shows the required attribution link. Snapshots older than a week before the requested date are not used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HA82gVKYyo9BHLHPW4qr4x
This commit is contained in:
parent
6b0c80bb50
commit
62c19192a7
13 changed files with 160 additions and 27 deletions
|
|
@ -138,7 +138,7 @@
|
|||
return owedOriginal(e);
|
||||
});
|
||||
|
||||
// Prefill the exchange rate from ECB rates. A rate typed by hand is kept
|
||||
// Prefill the exchange rate from the server's daily rates. A rate typed by hand is kept
|
||||
// when the date changes, but not when the currency does. An existing
|
||||
// expense keeps its stored rate until one of them changes.
|
||||
let lastCurrency = untrack(() => currency);
|
||||
|
|
@ -274,9 +274,11 @@
|
|||
oninput={() => (rateSource = 'manual')} />
|
||||
<span class="muted">{base}</span>
|
||||
</div>
|
||||
<!-- xr: rates come from ExchangeRate-API's free tier, which requires the attribution link. -->
|
||||
<p class="small muted" style:text-align="center">
|
||||
{#if rateMissing && rateSource !== 'manual'}{t('rate_unavailable')}
|
||||
{:else if rateSource.startsWith('ecb:')}{t('rate_source_ecb', { date: fmtDate(rateSource.slice(4)) })}
|
||||
{:else if rateSource.startsWith('xr:')}<a href="https://www.exchangerate-api.com" target="_blank" rel="noopener noreferrer">{t('rate_source_xr', { date: fmtDate(rateSource.slice(3)) })}</a>
|
||||
{:else}{t('rate_source_manual')}{/if}
|
||||
{#if amount && isValidRate(rateText.trim().replace(',', '.'))} · ≈ {money(Math.round(amount * Number(rateText.replace(',', '.')) * 10 ** (exponent(base) - exp)), base)}{/if}
|
||||
</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue