From 6e741a51fef24a8b30e9dc467a713d3b7dfad8d3 Mon Sep 17 00:00:00 2001 From: Atreides Assets Date: Fri, 30 Oct 2026 12:28:48 +0100 Subject: [PATCH] Versie 0.3.3 --- client/app.js | 4 +- client/css/styles.css | 97 ++- client/dashboard/dashboard.js | 4 +- client/data/hygiene.js | 10 - client/data/table-viewer.js | 7 - client/i18n/en.js | 121 ++-- client/i18n/nl.js | 203 +++--- client/pages/accounts.js | 5 +- client/pages/connections.js | 4 +- client/pages/conversion-bitcoin.js | 43 +- client/pages/db-file.js | 115 +++ client/pages/event-accounts.js | 7 +- client/pages/license.js | 148 ++-- client/pages/portfolios.js | 420 +++++++++++ client/pages/price-history.js | 790 --------------------- client/pages/system.js | 4 +- client/pages/valuations.js | 11 +- client/portfolio.js | 5 +- client/price/btc-explorer.js | 9 +- client/ui/activity.js | 4 +- client/ui/attention-sources.js | 4 +- client/ui/blur.js | 11 +- client/ui/hint.js | 18 +- client/ui/icons.js | 4 +- client/ui/source-matrix.js | 147 ---- client/wealth/return-view.js | 9 +- client/widgets/return.js | 27 +- package-lock.json | 4 +- package.json | 2 +- server/data/_limits.js | 5 +- server/data/accounts-merge.js | 4 +- server/data/dashboard.js | 10 +- server/data/onboarding.js | 8 +- server/data/valuations.js | 8 +- server/db/conn.mjs | 12 +- server/db/seeds.js | 7 +- server/demo.mjs | 131 ++++ server/index.mjs | 12 +- server/portfolios-admin.mjs | 37 +- server/portfolios.mjs | 7 +- shared/config.js | 9 +- shared/i18n/en.js | 4 +- shared/i18n/nl.js | 18 +- tests/db/seeds.test.mjs | 8 +- tests/price/btc-explorer-retry.test.mjs | 51 ++ tests/repo/license-limits.test.mjs | 33 +- tests/repo/merge.test.mjs | 302 -------- tests/server/license-portfolios.test.mjs | 11 +- tests/server/mcp-portfolio-switch.test.mjs | 13 +- tests/server/mcp-stdio.test.mjs | 18 +- tests/ui/aandacht-wisselkoers.test.mjs | 4 +- tests/ui/accountactiviteit.test.mjs | 19 +- tests/ui/ai-proposals-widget.test.mjs | 4 +- tests/ui/blur-spatie.test.mjs | 54 ++ tests/ui/gedeelde-machinerie.test.mjs | 429 ----------- tests/ui/hint.test.mjs | 22 +- tests/wealth/return-view.test.mjs | 20 +- 57 files changed, 1362 insertions(+), 2135 deletions(-) delete mode 100644 client/data/hygiene.js delete mode 100644 client/data/table-viewer.js create mode 100644 client/pages/db-file.js create mode 100644 client/pages/portfolios.js delete mode 100644 client/pages/price-history.js delete mode 100644 client/ui/source-matrix.js create mode 100644 server/demo.mjs create mode 100644 tests/price/btc-explorer-retry.test.mjs delete mode 100644 tests/repo/merge.test.mjs create mode 100644 tests/ui/blur-spatie.test.mjs delete mode 100644 tests/ui/gedeelde-machinerie.test.mjs diff --git a/client/app.js b/client/app.js index 8336f1d..e859be6 100644 --- a/client/app.js +++ b/client/app.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:98f4651e5cb7036965f92ae8206b5dd6cbf62ce4e42388c68825bc8d9de6ca9d +// Generated, do not edit. sha256:aa77d2c2decbc66af6d9704bd9aeefcdd539cbf767ac6818b097169d4cfa5aa8 import { configureSharedUi } from './ui/shared-setup.js'; import './edition.js'; import { assertConfig, ROUTE_KEYS, hashFromLocation } from '../shared/config.js'; @@ -21,7 +21,6 @@ import { clearPageHint } from './ui/page-hint.js'; import { refreshRecentCloses } from './price/providers.js'; import * as home from './pages/home.js'; import * as conversionBitcoin from './pages/conversion-bitcoin.js'; -import * as priceHistory from './pages/price-history.js'; import * as wealth from './pages/wealth.js'; import * as events from './pages/events.js'; import * as tracking from './pages/tracking.js'; @@ -41,7 +40,6 @@ registerRoute(ROUTE_KEYS.EVENTS, events); registerRoute(ROUTE_KEYS.VALIDATION, makeStub('validation')); registerRoute(ROUTE_KEYS.TRACKING, tracking); registerRoute(ROUTE_KEYS.CONVERSION_BITCOIN, conversionBitcoin); -registerRoute(ROUTE_KEYS.PRICE_HISTORY, priceHistory); registerRoute(ROUTE_KEYS.SYSTEM, system); registerRoute(ROUTE_KEYS.ACTIONS, actions); registerRoute(ROUTE_KEYS.GUIDE, guide); diff --git a/client/css/styles.css b/client/css/styles.css index cd7a935..eb2574f 100644 --- a/client/css/styles.css +++ b/client/css/styles.css @@ -1,4 +1,4 @@ -/* Generated, do not edit. sha256:d875d85b0d41e419eb6bae7090608b0914629b07925648a2d82dc7a8e8eb4309 */ +/* Generated, do not edit. sha256:3a6f73b7505bd7ec634402e61c222e218812ab7432c634bed61f9c0331123db5 */ :root { --logo-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Cpath d='M 46.108 37.099 L 79.826 68.032 L 113.068 37.288 L 142.067 37.244 L 92.564 85.773 L 92.367 123.544 L 80.04 135.851 L 67.262 123.517 L 67.425 85.773 L 17.176 37.092 L 46.108 37.099 Z'/%3E%3Cpath d='M 49.901 91.273 L 0 43.722 L 0 24.666 L 64.78 87.731 L 64.689 118.25 L 50.234 105.711 L 49.901 91.273 Z'/%3E%3Cpath d='M 95.221 87.779 L 160 24.149 L 160 43.383 L 109.554 93.918 L 109.584 105.756 L 94.924 118.584 L 95.221 87.779 Z'/%3E%3C/svg%3E"); --radius-sm: 8px; @@ -1220,8 +1220,8 @@ tbody tr[data-row-id]:hover .exp-cell .chev-btn { color:var(--accent); } .ip-due-row > .ip-num { min-width:5.5rem; } .ip-due-btns { display:flex; gap:0.4rem; } -.table-wrap.sticky-sel tbody tr.row-selected > td { position:sticky; top:var(--sticky-row-top, 2.7rem); z-index:2; background:color-mix(in srgb, var(--accent) 20%, var(--bg-elevated)); } -.table-wrap.sticky-sel tbody tr.row-selected:hover > td { background:color-mix(in srgb, var(--accent) 30%, var(--bg-elevated)); } +.table-wrap.sticky-sel > table > tbody > tr.row-selected > td { position:sticky; top:var(--sticky-row-top, 2.7rem); z-index:2; background:color-mix(in srgb, var(--accent) 20%, var(--bg-elevated)); } +.table-wrap.sticky-sel > table > tbody > tr.row-selected:hover > td { background:color-mix(in srgb, var(--accent) 30%, var(--bg-elevated)); } .cmd-bar { position:fixed; left:50%; bottom:1.8rem; transform:translateX(-50%); z-index:60; @@ -1365,6 +1365,37 @@ button.wealth-year-chip:hover { background:var(--accent-mid); } } .pf-blok + .pf-blok { margin-top:1.4rem; padding-top:1.4rem; border-top:1px solid var(--border); } .pf-blok:first-of-type { margin-top:1rem; } +.pf-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(min(24rem, 100%), 1fr)); grid-auto-rows:1fr; gap:1.5rem; } +.pf-grid-archive { grid-auto-rows:auto; align-items:start; margin-top:1.5rem; } +.pf-grid.is-stacked { grid-template-columns:minmax(0, 1fr); max-width:46rem; } +.pf-card { display:flex; flex-direction:column; } +.pf-card.is-open { border-color:var(--accent); } +.pf-head { display:flex; align-items:center; gap:0.7rem; flex-wrap:wrap; } +.pf-head-end { margin-left:auto; } +.pf-name { font-size:1.9rem; font-weight:700; letter-spacing:-0.025em; line-height:1.15; } +.pf-sub { margin-top:0.3rem; min-height:1.4em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.pf-facts { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:0.6rem; margin:1.3rem 0 0; } +.pf-fact { min-width:0; padding:0.65rem 0.85rem; border-radius:var(--radius-sm); background:var(--surface-tint); } +.pf-fact:empty { background:transparent; } +.pf-fact > * { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.pf-fact dt { font-size:0.78rem; color:var(--text-ter); } +.pf-fact dd { margin:0.15rem 0 0; font-variant-numeric:tabular-nums; } +.pf-fact.is-late dd { color:var(--sig-yellow); } +.pf-kinds { list-style:none; margin:0.45rem 0 0; padding:0; min-height:calc(var(--pf-lines, 1) * 1.45em); font-size:0.8rem; color:var(--text-ter); white-space:normal; } +.pf-kinds li { display:flex; justify-content:space-between; gap:0.8rem; line-height:1.45; } +.pf-kinds li > span:last-child { font-variant-numeric:tabular-nums; color:var(--text-sec); } +.pf-actions { display:flex; align-items:center; gap:0.5rem; margin-top:auto; padding-top:1.4rem; } +.pf-actions:empty { display:none; } +.pf-more { margin-left:auto; min-width:2.2rem; letter-spacing:0.08em; } +.pf-archive { display:block; } +.dialog--wide.pf-settings-dialog { max-width:min(36rem, 100%); } +.pf-archive > summary { cursor:pointer; list-style:none; display:flex; align-items:center; gap:0.6rem; } +.pf-archive > summary::-webkit-details-marker { display:none; } +.pf-archive[open] > summary .chev-btn { transform:rotate(180deg); } +.pf-archive-list { display:flex; flex-direction:column; gap:0.9rem; margin-top:1.2rem; } +.pf-new { display:flex; align-items:center; justify-content:center; gap:0.5rem; min-height:12rem; padding:1.6rem; border:1.5px dashed var(--border-mid); border-radius:var(--radius-lg); color:var(--text-ter); } +.pf-new-btn { width:4rem; height:4rem; border-radius:var(--radius-lg); } +.pf-new-btn svg { width:28px; height:28px; } .wealth-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(min(22rem, 100%), 1fr)); gap:1.2rem; align-items:stretch; } .gap-list { max-height:16rem; overflow-y:auto; margin-top:0.4rem; } @@ -1471,6 +1502,7 @@ textarea.notes-body { flex:1 1 auto; min-height:8rem; resize:none; line-height:1 .return-w-amount { margin:0.4rem 0 0.1rem; color:var(--text-sec); } .return-w-pct { font-size:0.85rem; font-variant-numeric:tabular-nums; } .return-view--widget { margin-top:0.6rem; } +.return-view--widget .return-plot > .t-muted-cell { display:grid; place-items:center; height:100%; padding:0 var(--padding-x); text-align:center; } .return-view--widget .return-plot { height:8rem; margin:0 calc(-1 * var(--padding-x)) calc(-1 * var(--padding)); overflow:hidden; border-radius:0 0 var(--radius) var(--radius); } .wealth-detail .return-plot { height:min(12rem, 22vh); } @@ -1526,6 +1558,8 @@ html:not(:has(.page-layout > .page-aside)) .hint-panel { width:min(44rem, calc(100vw - var(--hint-line-x) - 2.8rem)); } .hint:hover .hint-panel, .hint-btn:focus-visible + .hint-panel { opacity:1; visibility:visible; transform:translateY(0); } +.hint.is-open .hint-panel { opacity:1; visibility:visible; transform:translateY(0); pointer-events:auto; } +.hint.is-open .hint-btn { opacity:1; color:var(--accent-text); } @media (min-width:769px) { #page-hint .hint-panel.is-wide { right:auto; left:calc(var(--hint-line-x) + 1.4rem); @@ -1721,11 +1755,13 @@ tbody tr:hover .copy-btn, .mv-row:hover .copy-btn, .card-flat:hover .copy-btn { .flex { display:flex; align-items:center; } .flex-between { display:flex; align-items:center; justify-content:space-between; } .hidden { display:none !important; } -.price-hero { display:flex; align-items:center; justify-content:space-between; gap:1.5rem; flex-wrap:wrap; margin-bottom:1.2rem; } +.conv-card { container-type:inline-size; display:flex; flex-direction:column; gap:1.2rem; } .price-label { margin-bottom:0.35rem; display:flex; align-items:center; gap:0.5rem; } .price-val { font-size:2.1rem; letter-spacing:-0.03em; line-height:1.1; } .price-meta { font-size:0.72rem; color:var(--text-ter); margin-top:0.35rem; } -.conv-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr)); gap:0.9rem; } +.conv-grid { display:grid; grid-template-columns:repeat(6, minmax(0, 1fr)); gap:0.9rem; } +@container (max-width:980px) { .conv-grid { grid-template-columns:repeat(3, minmax(0, 1fr)); } } +@container (max-width:480px) { .conv-grid { grid-template-columns:repeat(2, minmax(0, 1fr)); } } .field { display:flex; flex-direction:column; gap:0.6rem; background:var(--bg-elevated); border:1px solid var(--border); --radius:var(--radius-lg); --padding:1.1rem; border-radius:var(--radius); padding:1.1rem 1.2rem; transition:border-color 0.15s, background 0.25s; } .field:focus-within { border-color:var(--accent); } .field-head { display:flex; align-items:center; justify-content:space-between; gap:0.5rem; } @@ -1734,15 +1770,7 @@ tbody tr:hover .copy-btn, .mv-row:hover .copy-btn, .card-flat:hover .copy-btn { .field-input::placeholder { color:var(--text-ter); font-weight:400; } .field-input:focus { border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); } .field-hint { font-size:0.7rem; color:var(--text-sec); font-variant-numeric:tabular-nums; } -.info { background:var(--bg-elevated); border:1px solid var(--border); border-radius:var(--radius-lg); padding:1.3rem 1.4rem; margin-top:1.2rem; } -.info-title { margin-bottom:0.8rem; } -.info-body { font-size:0.82rem; color:var(--text-sec); line-height:1.8; font-variant-numeric:tabular-nums; } -.info-body strong { color:var(--text-primary); font-weight:600; } -.info-note { margin-top:0.7rem; font-size:0.8rem; color:var(--text-sec); } -.conv-footer { margin-top:1.5rem; text-align:center; font-size:0.72rem; color:var(--text-ter); } @media (max-width:560px) { - .price-hero { flex-direction:column; align-items:stretch; } - .conv-grid { grid-template-columns:1fr; } .price-val { font-size:1.8rem; } } @@ -1759,11 +1787,7 @@ tbody tr:hover .copy-btn, .mv-row:hover .copy-btn, .card-flat:hover .copy-btn { .lic-head { display:flex; align-items:baseline; justify-content:space-between; gap:1rem; margin-bottom:1.2rem; } .lic-card p { margin:0 0 0.8rem; overflow-wrap:break-word; } -.lic-drop { display:grid; gap:0.2rem; place-items:center; padding:1.6rem; border:1px dashed var(--border-mid); border-radius:var(--radius-md); cursor:pointer; transition:border-color 0.15s, background 0.15s; } -.lic-drop:hover, .lic-drop:focus-visible { border-color:var(--accent); } -.lic-drop.is-over { border-color:var(--accent); background:var(--accent-soft); } - -.lic-layout { display:grid; gap:1.5rem; align-items:start; grid-template-columns:minmax(20rem, 28rem) minmax(0, 1fr); } +.lic-layout { display:grid; gap:1.5rem; align-items:start; grid-template-columns:minmax(0, 1fr) minmax(17rem, 24rem); } .lic-side, .lic-main { display:flex; flex-direction:column; gap:1.5rem; min-width:0; } .lic-hero { display:flex; flex-direction:column; align-items:center; gap:1rem; margin-bottom:1.6rem; } @@ -1771,7 +1795,8 @@ tbody tr:hover .copy-btn, .mv-row:hover .copy-btn, .card-flat:hover .copy-btn { .lic-feat-row { display:grid; grid-template-columns:minmax(0, 1fr) 5rem 5rem; align-items:center; justify-items:center; padding:0.4rem 0.5rem; border-radius:var(--radius-sm); cursor:default; } .lic-feat-row > :first-child { justify-self:start; } -.lic-feat-row[data-feature]:hover, .lic-feat-row[data-feature]:focus-visible, .lic-feat-row.is-on { background:var(--neutral-bg); outline:none; } +.lic-feat-row[data-feature]:focus-visible, .lic-feat-row.is-on { background:var(--neutral-bg); outline:none; } +.lic-feat-row :is(.lic-feat-yes, .lic-feat-no, .lic-feat-part, .lic-feat-open) { cursor:help; } .lic-feat-cols { font-weight:500; color:var(--text-sec); font-size:0.8rem; padding-top:0; } .lic-group + .lic-group { border-top:1px solid var(--border); } .lic-group > summary { list-style:none; cursor:pointer; padding:0.7rem 0.5rem; font-size:1.05rem; font-weight:500; } @@ -1784,26 +1809,22 @@ tbody tr:hover .copy-btn, .mv-row:hover .copy-btn, .card-flat:hover .copy-btn { .lic-feat-yes svg { width:1.4rem; height:1.4rem; } .lic-feat-sub .lic-feat-yes svg { width:1.1rem; height:1.1rem; } .lic-feat-no, .lic-feat-open { color:var(--text-sec); font-size:1.2rem; line-height:1; } -.lic-feat-part { color:var(--text-sec); font-size:0.8rem; font-weight:400; } +.lic-feat-part { color:var(--text-ter); display:inline-flex; } +.lic-feat-part svg { width:1.4rem; height:1.4rem; } .lic-feat-shot[hidden] { display:none; } .lic-feat-shot { position:fixed; z-index:1000; width:min(34rem, calc(100vw - 1rem)); aspect-ratio:16 / 10; display:grid; place-items:center; padding:0.6rem; text-align:center; overflow:hidden; pointer-events:none; background:var(--bg-raised); border:1px solid var(--border-mid); border-radius:var(--radius-md); box-shadow:0 12px 40px rgba(0,0,0,0.35); } .lic-feat-img { max-width:100%; max-height:100%; object-fit:contain; border-radius:var(--radius-sm); }.lic-section { border-top:1px solid var(--border); margin-top:1.2rem; padding-top:1.2rem; } -.lic-card .lic-drop { padding:0.8rem; margin-bottom:0.6rem; } -.lic-apps { margin:0.2rem 0 0.8rem; } -.lic-apps .t-caption { margin-bottom:0.3rem; } -.lic-card .lic-apps p { margin:0 0 0.4rem; } -.lic-more summary { cursor:pointer; color:var(--text-sec); margin-top:0.4rem; } -.lic-more[open] summary { margin-bottom:0.8rem; } +.lic-section[hidden] { display:none; } +.lic-card .lic-status { margin-top:0.9rem; } +.lic-attach { margin-left:auto; display:inline-flex; align-items:center; } -.lic-chat-card { position:sticky; top:0; display:flex; flex-direction:column; height:calc(100vh - 11rem); min-height:30rem; } +.lic-chat-card { display:flex; flex-direction:column; } .lic-chat-card[hidden] { display:none; } -.lic-chat { flex:1; display:flex; flex-direction:column; gap:0.8rem; min-height:8rem; overflow-y:auto; padding:0.25rem 0.25rem 0.5rem; margin-bottom:1rem; } -@media (max-width:1100px) { +.lic-chat { display:flex; flex-direction:column; gap:0.8rem; min-height:6rem; max-height:20rem; overflow-y:auto; padding:0.25rem 0.25rem 0.5rem; margin-bottom:1rem; } +@media (max-width:820px) { .lic-layout { grid-template-columns:minmax(0, 1fr); } - .lic-chat-card { position:static; height:auto; } - .lic-chat { flex:none; max-height:28rem; } } .lic-msg { display:flex; flex-direction:column; gap:0.2rem; max-width:75%; } .lic-msg.is-mine { align-self:flex-end; align-items:flex-end; } @@ -2261,7 +2282,7 @@ td:hover .po-btn, .po-host:hover .po-btn { color:var(--accent-text); } .table-wrap tr.row-editing td[data-label] .input, .table-wrap tr.row-editing td[data-label] .conv-field { width:100%; } - .table-wrap.sticky-sel tbody tr.row-selected > td { position:static; } + .table-wrap.sticky-sel > table > tbody > tr.row-selected > td { position:static; } } .health-start { display:flex; align-items:center; gap:0.8rem; flex-wrap:wrap; margin-bottom:0.6rem; } @@ -2388,22 +2409,22 @@ td:hover .po-btn, .po-host:hover .po-btn { color:var(--accent-text); } :root[data-profile="glass"][data-rowsel="pill"] .table-wrap.sticky-sel { --sel-fill:color-mix(in srgb, var(--accent) 8%, transparent); --sel-fill-hover:color-mix(in srgb, var(--accent) 13%, transparent); } -:root[data-profile="glass"] .table-wrap.sticky-sel tbody tr.row-selected { background:none; } -:root[data-profile="glass"] .table-wrap.sticky-sel tbody tr.row-selected > td { +:root[data-profile="glass"] .table-wrap.sticky-sel > table > tbody > tr.row-selected { background:none; } +:root[data-profile="glass"] .table-wrap.sticky-sel > table > tbody > tr.row-selected > td { background:linear-gradient(var(--sel-fill), var(--sel-fill)); backdrop-filter:blur(var(--float-blur)); -webkit-backdrop-filter:blur(var(--float-blur)); } -:root[data-profile="glass"] .table-wrap.sticky-sel tbody tr.row-selected:hover > td { +:root[data-profile="glass"] .table-wrap.sticky-sel > table > tbody > tr.row-selected:hover > td { background:linear-gradient(var(--sel-fill-hover), var(--sel-fill-hover)); } -:root[data-profile="glass"]:not([data-rowsel="tint"], [data-rowsel="pill"]) .table-wrap.sticky-sel tbody tr.row-selected > td { +:root[data-profile="glass"]:not([data-rowsel="tint"], [data-rowsel="pill"]) .table-wrap.sticky-sel > table > tbody > tr.row-selected > td { background-image:linear-gradient(192deg, color-mix(in srgb, var(--accent) 20%, transparent), color-mix(in srgb, var(--accent) 5%, transparent) 45%, transparent 85%); background-size:var(--row-w, 100%) 100%; background-position:calc(-1 * var(--cell-x, 0px)) 0; background-repeat:no-repeat; transition:background-color 0.25s; } -:root[data-profile="glass"]:not([data-rowsel="tint"], [data-rowsel="pill"]) .table-wrap.sticky-sel tbody tr.row-selected:hover > td { +:root[data-profile="glass"]:not([data-rowsel="tint"], [data-rowsel="pill"]) .table-wrap.sticky-sel > table > tbody > tr.row-selected:hover > td { background-image:linear-gradient(var(--row-hover), var(--row-hover)), linear-gradient(192deg, color-mix(in srgb, var(--accent) 20%, transparent), color-mix(in srgb, var(--accent) 5%, transparent) 45%, transparent 85%); background-size:100% 100%, var(--row-w, 100%) 100%; background-position:0 0, calc(-1 * var(--cell-x, 0px)) 0; @@ -2572,7 +2593,7 @@ td:hover .po-btn, .po-host:hover .po-btn { color:var(--accent-text); } } :root[data-profile="glass"] .dialog::before { background:var(--bg-elevated); backdrop-filter:none; -webkit-backdrop-filter:none; } :root[data-profile="glass"] .table-wrap { --head-fill:var(--bg-elevated); } - :root[data-profile="glass"] .table-wrap.sticky-sel tbody tr.row-selected > td { + :root[data-profile="glass"] .table-wrap.sticky-sel > table > tbody > tr.row-selected > td { background:color-mix(in srgb, var(--accent) 20%, var(--bg-elevated)); backdrop-filter:none; -webkit-backdrop-filter:none; } } diff --git a/client/dashboard/dashboard.js b/client/dashboard/dashboard.js index a357efc..dbf2b32 100644 --- a/client/dashboard/dashboard.js +++ b/client/dashboard/dashboard.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:890b0e46a8d4907e79564933d64186ce26573ba305bedb6fd4fa2f911700fadc +// Generated, do not edit. sha256:bcd0e4843e173e4a2001dd1d3c642e65fcb325797f24f09e8d0e152ff13debcf import { getPref, setPref } from '../data/preferences.js'; import { activateProfile, activeProfile, createProfile, deleteProfile, listProfiles, listWidgets, @@ -375,6 +375,7 @@ async function profileAction(host, opts, act, btn) { const res = await dialog.form({ title: t('dashboard.profileNew'), fields: [{ key: 'name', label: t('dashboard.profileNewPrompt'), value: '' }], + confirmLabel: t('common.create'), }); if (!res || !String(res.name || '').trim()) return; await activateProfile(await createProfile({ name: res.name })); @@ -383,6 +384,7 @@ async function profileAction(host, opts, act, btn) { const res = await dialog.form({ title: t('dashboard.profileRename'), fields: [{ key: 'name', label: t('dashboard.profileRenamePrompt'), value: huidig.name }], + confirmLabel: t('common.rename'), }); if (!res || !String(res.name || '').trim()) return; await renameProfile(huidig.id, { name: res.name }); diff --git a/client/data/hygiene.js b/client/data/hygiene.js deleted file mode 100644 index 7df2985..0000000 --- a/client/data/hygiene.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated, do not edit. sha256:3d2479ecc3a9b127fd96f6f5e0ff246e37273a0096ff4f6b4225e400506ea204 -import { rpc } from './_rpc.js'; - -export const acceptHygieneFinding = (...args) => rpc('hygiene', 'acceptHygieneFinding', ...args); -export const fillDerivablePriceOrigins = (...args) => rpc('hygiene', 'fillDerivablePriceOrigins', ...args); -export const hygieneFingerprint = (...args) => rpc('hygiene', 'hygieneFingerprint', ...args); -export const hygieneKinds = (...args) => rpc('hygiene', 'hygieneKinds', ...args); -export const hygieneReport = (...args) => rpc('hygiene', 'hygieneReport', ...args); -export const listHygieneAcceptances = (...args) => rpc('hygiene', 'listHygieneAcceptances', ...args); -export const unacceptHygieneFinding = (...args) => rpc('hygiene', 'unacceptHygieneFinding', ...args); diff --git a/client/data/table-viewer.js b/client/data/table-viewer.js deleted file mode 100644 index 02621e8..0000000 --- a/client/data/table-viewer.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated, do not edit. sha256:c0d23ea37ddc6695c69eb1b6531c8b951887f5c30452dd318610fcfcb868477c -import { rpc } from './_rpc.js'; - -export const clearTable = (...args) => rpc('table-viewer', 'clearTable', ...args); -export const deleteTableRow = (...args) => rpc('table-viewer', 'deleteTableRow', ...args); -export const listTableRaw = (...args) => rpc('table-viewer', 'listTableRaw', ...args); -export const tableColumns = (...args) => rpc('table-viewer', 'tableColumns', ...args); diff --git a/client/i18n/en.js b/client/i18n/en.js index 55f324b..e7ca4eb 100644 --- a/client/i18n/en.js +++ b/client/i18n/en.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:a167e18e55f858b6191c5f1c50bdab5b3bf485873744837c0e096e77f639cd0e +// Generated, do not edit. sha256:b049624ea50293251291f47db3c7beed3e81db7ec2c5e36ca24f472c360c5f37 import { nl } from './nl.js'; export const en = { @@ -13,6 +13,8 @@ export const en = { requestTooLarge: 'The request is too large.', fileTooLarge: 'The file is too large.', invalidAmount: 'Invalid amount.', + create: 'Create', + rename: 'Rename', }, splash: { @@ -72,20 +74,14 @@ export const en = { 'why_unknown-version': 'The app version cannot be determined', why_licensed: 'Valid license', cardTitle: 'License', - cardFree: 'This installation runs the free version: no time limit, with a small set of records and ' - + 'without the connections, the source choice and the taxes page. Reading and exporting always ' - + 'keep working; nothing is ever removed.', - cardBuy: 'The paid version lifts those limits. If you have a license file, drop it below.', - cardFull: 'This installation runs the full version. All limits are lifted and every feature is ' - + 'available.', - cardDevelop: 'This is a development version: below 1.0.0 the app restricts nothing.', - cardFacts: 'The license is for {buyer}, issued on {issued} and valid for major versions {from} ' - + 'through {to}.', - cardOutOfRange: 'This app is version {version} and falls outside that range.', + cardFree: 'Free version: no time limit, with a small set of records. Nothing is ever removed.', + cardFull: 'Full version: all limits lifted.', + cardFor: 'This license is for {npub}', + cardFacts: 'Issued on {issued}, valid for major versions {from} through {to}.', cardProblem: 'There is a license file, but the app cannot use it.', cardVersion: 'Version {version}', signInTitle: 'Sign in', - signInIntro: 'Your license belongs to a nostr key. Sign in to fetch the licenses for that key.', + signInIntro: 'Sign in with your nostr key to buy or fetch your license.', signInLast: 'Last signed in as {npub}.', signInExtension: 'With extension', signInExtensionNone: 'No nostr extension found in this browser (such as Alby or nos2x).', @@ -126,7 +122,6 @@ export const en = { buyClosed: 'Sales are closed at the moment.', buyAway: 'Atreides Services cannot be reached right now, so buying is not possible at the moment. ' + 'Try again later.', - buySignInFirst: 'Sign in first: the license is issued to your key.', buyButton: 'Buy', buyInvoice: 'Pay this invoice with a Lightning wallet. It is valid until {time}.', buyOpenWallet: 'Open in wallet', @@ -183,8 +178,7 @@ export const en = { + 'ID check).', payNote: 'As of October 2026: check the terms with the provider.', nostrMore: 'About nostr and your key', - signInKnown: 'Your license is on {npub}. Sign with that key to fetch licenses, buy or ask for ' - + 'support; the npub alone does not prove it is you.', + signInKnown: 'Use the key this license is on.', infoNostrHead: 'What is nostr?', infoNostr: 'Nostr is an open protocol in which your identity is a key pair. The public key (npub) is ' + 'like an address: anyone may see it. The secret key (nsec) is like a password that no one can ' @@ -211,17 +205,14 @@ export const en = { + 'made unrecognizable, so it can only be matched if you come forward with it yourself.', name_fiatAccounts: 'Fiat accounts', name_assets: 'Assets besides currencies', - name_valuations: 'Balances', name_portfolios: 'Portfolios', featTitle: 'What the editions include', featFull: 'Full', featFree: 'Free', - featFreeOpen: 'What the free edition includes is not settled yet.', featNoShot: 'No screenshot of this feature yet.', featIncluded: 'Included', featExcluded: 'Not included', featUndecided: 'Not decided yet', - featPartial: 'partly', featPartialTitle: 'Part of it is included', featGroup_overview: 'Overview and reports', featGroup_bitcoin: 'Bitcoin and Lightning', @@ -238,22 +229,19 @@ export const en = { feat_balances: 'Balances and reconcile', feat_ownMempool: 'Your own mempool node', feat_priceHistory: 'Price history', - feat_sourceChoice: 'Source choice per asset', - feat_providerKeys: 'Your own price sources and API keys', + feat_sourceChoice: 'Source choice matrix', + feat_providerKeys: 'Managing your own integrations and API keys', feat_signals: 'Bitcoin signals, charts and widget', feat_netshare: 'Network share widget', feat_portfolios: 'Multiple portfolios', feat_ai: 'AI connection (MCP)', + feat_accountMerge: 'Merging accounts', feat_import: 'Import and export', feat_data: 'Data: the raw tables', feat_health: 'Health: checks on your records', feat_kiosk: 'The app in its own window', feat_metals: 'Precious metals, coins and bars', unlimited: 'unlimited', - dropHere: 'Drag the license file here', - dropOr: 'or click to choose one', - dropTooBig: 'That file is far too large for a license. The license file is a small JSON file of a ' - + 'few lines at most.', installOk: 'License saved. The app is now the full version.', installOkFuture: 'License saved, but it does not cover this major version. The app stays in the free ' + 'version for now.', @@ -332,14 +320,14 @@ export const en = { nwcRelayRefusedNoReason: 'The relay refuses the request and does not say why.', nwcDecryptFailed: 'Decrypting the response failed: {reden}', kindMarket: 'Atreides Services', - usedByMarket: "The app's own price service, for prices, the license and support. Address and token apply to the whole installation, so to every portfolio. The app talks to the service through its own server; the token stays server-side and never comes back to the browser.", + usedByMarket: "The app's own price service, for prices, the license and support. Address and token apply to the whole installation, so to every portfolio.", marketConfigure: 'Configure', marketDialogTitle: 'Configure Atreides Services', marketTokenUnset: 'no token', - marketTokenLicense: 'token from the license ({tier})', - marketTokenManual: 'custom token', - marketTokenPending: 'the app requests a token with the license', - marketTokenNoLicense: 'no license to request a token with', + marketTokenLicense: 'Token from the license ({tier})', + marketTokenManual: 'Custom token', + marketTokenPending: 'The app requests a token with the license', + marketTokenNoLicense: 'No license to request a token with', marketOverrideUrl: 'development address', marketTestOk: '{app} {version} · {n} instruments', marketSpot: 'What the app fetches from the service', @@ -436,14 +424,14 @@ export const en = { addNoFit: 'Not enough space here for the remaining widgets', addNone: 'Everything has been added', profile: 'Layout', - profileNew: 'New layout…', + profileNew: 'New layout', profileNewPrompt: 'Name of the new layout', - profileRename: 'Rename…', + profileRename: 'Rename', profileRenamePrompt: 'New name for this layout', - profileDelete: 'Delete this layout…', + profileDelete: 'Delete this layout', profileDeleteConfirm: 'Delete this layout and all its widgets? The other layouts remain.', profileSystemHint: 'The default layout cannot be renamed.', - profileRestart: 'Start default layout over…', + profileRestart: 'Start default layout over', profileRestartConfirm: 'Start the default layout over? What you placed yourself is removed and the default layout takes its place.', nameRequired: 'A layout needs a name.', unknownProfile: 'Layout #{id} does not exist.', @@ -610,7 +598,7 @@ export const en = { kindSourceChoice: 'Source choice', sourceFirst: 'first', sourceRemove: 'remove', - sourceChoiceNote: 'You can see the chain as it stands now on Integrations, Source choice, or on the Source tab of Price history.', + sourceChoiceNote: 'You can see the chain as it stands now on Integrations, Source choice, or on the Prices tab of Price history.', unknownKind: 'Unknown kind of proposal', ledger: 'ledger', diff: 'difference', @@ -928,7 +916,7 @@ export const en = { finish: 'Set up', persona_bitcoin: 'Bitcoin only', persona_broad: 'Broader', - rerun: 'Set up…', + rerun: 'Set up', }, notes: { tab: 'Notes', @@ -1236,9 +1224,7 @@ export const en = { fiatHint: 'Traditional currency', btcHint: 'Base unit · max 21 million', hierarchy: 'Unit hierarchy', - satNote: 'The satoshi is the smallest on-chain unit. The millisatoshi exists only on the Lightning Network.', - footer: 'Live price from the selected price source', - }, + satNote: 'The satoshi is the smallest on-chain unit. The millisatoshi exists only on the Lightning Network.', }, labels: { title: 'Labels', @@ -1301,6 +1287,7 @@ export const en = { merge: 'Merge', mergeTitle: 'Merge two accounts into one', mergeNeedTwo: 'You need at least two accounts to merge.', + mergePaid: 'Merging accounts is part of the full edition.', mergePick: '(choose an account)', mergeKeep: 'Account to keep', mergeDrop: 'Account to remove', @@ -1544,7 +1531,6 @@ export const en = { }, valuations: { - maxFree: 'The free version is limited to {max} balance. A license removes that limit; nothing is removed in the meantime.', title: 'Balances', needAsset: 'Create an asset first or migrate the data on the overview.', colDate: 'Reference date', @@ -1979,7 +1965,6 @@ export const en = { provToGaps: 'Go to this gap under Gaps', provSpotNote: 'up to {pct} off the closing price', provCarriedNote: 'up to {n} days old', - tabSource: 'Source', diagCard_noCoverage: 'No integration provides prices', diagCard_allInactive: '{namen} is turned off', diagCard_noChoice: 'No source selected', @@ -2146,58 +2131,72 @@ export const en = { archiveFull: 'The archive is full of folders named "{naam}"; clean up a few first.', notInArchive: 'There is no "{naam}" in the archive.', passwordRequired: 'Enter a password.', - intro: 'Each portfolio is a separate set of records: its own database and its own secrets, in its own folder. Exactly one is always open.', + intro: 'Each portfolio is a separate set of records: its own database and its own secrets, in its own folder. Exactly one is always open; its card comes first.', openNow: 'Open now', - activate: 'Open…', + activate: 'Open', activateConfirm: 'Switch to "{naam}"? The app restarts to do this.', activateWaiting: 'The app is restarting…', activateNoSupervisor: 'The choice is saved, but this app was started without the supervisor (npm run start:server). Close the app and start it again to work in "{naam}".', - create: 'New portfolio…', + create: 'New portfolio', + createConfirm: 'Create', createName: 'Name', createNameHint: 'The name becomes the folder name on disk.', createCurrency: 'Base currency', createDone: 'Portfolio "{naam}" created.', - copy: 'Copy…', + copy: 'Copy', copyTitle: 'Copy of "{naam}"', copyName: 'Name of the copy', copyConfirm: 'Copy', copyDone: 'Portfolio "{naam}" created as a copy of "{bron}".', - createHint: 'New portfolio gives fresh records without connections. You copy a portfolio from the list; a copy takes the database and the secrets along together, because a secret belongs to a row and only fits that database.', + createHint: 'New portfolio gives fresh records without connections. You copy a portfolio through the menu (…) on its card; a copy takes the database and the secrets along together, because a secret belongs to a row and only fits that database.', createCurrencyHint: 'The base currency is the currency the portfolio calculates in and shows all amounts in. You choose it for a new portfolio and after that it is fixed; a copy keeps the currency of the original.', - rename: 'Rename…', + rename: 'Rename', renameTo: 'New name', renameDone: 'Renamed to "{naam}".', renameActive: 'The portfolio that is open now cannot be renamed: its database is open. Switch to another one first.', - remove: 'Delete…', + remove: 'Delete', removeConfirm: 'Delete portfolio "{naam}"? The folder moves to the archive; nothing is erased. Type the name to confirm.', removeTypeLabel: 'Type the name', removeMismatch: 'That is not the name; nothing was changed.', removeDone: '"{naam}" is now in the archive.', - empty: 'There is no other portfolio yet.', noDatabase: 'no database yet', - lastUsed: 'last used', never: 'not used yet', + cardSince: '{munt}, since {jaar}', + factAssets: 'Assets in use', + factAccounts: 'Active accounts', + factEvents: 'Entries', + factValuations: 'Balances', + factLastUsed: 'Last used', + factBackup: 'Last backup', + backupNever: 'never', + more: 'More actions', + backupTitle: 'Backup', + backupLateHint: 'The last backup turns orange when it is older than {dagen} days or none was ever made. Restore and start empty sit in the menu (…) of the portfolio that is open and apply only to it.', + archiveCount: 'Archive ({n})', + demoBadge: 'Example', + demoHint: 'Demo is example records with bitcoin, an exchange, a wallet of your own and a bank account, filled over the past two and a half years. It does not count towards the limit of the free edition. Opening it is a restart; so is going back to your own portfolio.', archiveTitle: 'Archive', archiveIntro: 'Deleted portfolios are kept here. They no longer count anywhere, but the files still exist.', - archiveEmpty: 'The archive is empty.', - purge: 'Delete permanently…', + purge: 'Delete permanently', purgeConfirm: 'Permanently delete the folder of "{naam}" and everything in it? The database, secrets and history will be gone. This cannot be undone. Type the name to confirm.', purgeDone: '"{naam}" has been permanently deleted.', - settingsTitle: 'Settings of this portfolio', + settingsButton: 'Settings', + settingsOf: 'Settings of {naam}', hintTitle: 'What you see here', authTitle: 'Access to this portfolio', - authNone: 'No password set. The app can therefore only be reached from this machine.', + authNone: 'No password set.', authSet: 'A password is set.', authEnv: 'Set through the environment variable ASSETAPP_PASSWORD. As long as that is set, it overrides what you enter here.', - authChange: 'Set or change…', - authClear: 'Clear…', + authChange: 'Set password', + authSave: 'Save', + authClear: 'Clear', authPassword: 'Password', authClearConfirm: 'Remove the password of this portfolio? After that the app can only be reached from this machine.', authDone: 'Saved. It applies from the next time the app starts.', authClearedDone: 'Removed. It applies from the next time the app starts.', authLogout: 'Sign out', authLogoutConfirm: 'Sign out? You need to enter the password again to continue.', - authHint: 'Access from another device requires a certificate and sign-in credentials. The certificate belongs to this installation; the credentials to this portfolio.', + authHint: 'Without a password the app can only be reached from this machine. Access from another device requires a certificate and sign-in credentials. The certificate belongs to this installation; the credentials to this portfolio.', startYearTitle: 'Start year of these records', startYearLabel: 'Start reports at', startYearAuto: 'Automatic (from the first entry)', @@ -2214,7 +2213,6 @@ export const en = { mwrHint: 'This changes the percentages on the taxes page. Modified Dietz always gives a figure; IRR is more accurate but does not always have a solution, for example with a position that drops to zero in between. The chosen method is always shown with the figure.', }, dbfile: { - title: 'All records', passTooShort: 'Choose a password of at least 8 characters for the backup.', notABackup: 'This file is not an AssetApp backup (too short).', notABackupUseRestore: 'This file is not an AssetApp backup. You restore a separate .sqlite file with "Restore".', @@ -2231,20 +2229,21 @@ export const en = { versionNewerThanApp: 'This database is version {versie} and therefore newer than the app ({app}). Update the app before you restore it.', emptyFile: 'Empty file received.', notSqlite: 'This is not an SQLite file (the file header does not match).', - backup: 'Back up…', + backup: 'Backup', + backupConfirm: 'Back up', backupPass: 'Password for the backup', backupPassAgain: 'Repeat password', backupPassMismatch: 'The two passwords do not match.', backupDone: 'Backup created. Keep the password safe: without the password the backup cannot be restored.', export: 'Export database', - import: 'Restore…', + import: 'Restore', confirmRestoreBackup: 'Restore this backup? This replaces the database AND the secrets (secrets.json in the folder of this portfolio). The previous version of both is kept as .previous.', restoredSecrets: 'Secrets restored as well:', confirmImport: 'Replace the current database with this file? The previous one is kept as .previous next to the database file.', importDone: 'Database restored', importOrphans: 'Note, orphaned references found:', hint: 'The backup contains the database and the secrets, encrypted. The export is only the database: enough to read, not enough to restore everything.', - fresh: 'Start empty…', + fresh: 'Start empty', confirmFresh: 'Start with empty records? A fresh database is put into use; the current one is kept as .previous next to the database file. Make a backup first if you might ever need it again.', freshWord: 'empty', freshTypeLabel: 'Type the word to confirm', @@ -2266,7 +2265,7 @@ export const en = { nSkipped: 'skipped', account: 'Account (exchange) for this import', chooseAccount: '(choose account)', - newAccount: '+ new exchange account…', + newAccount: '+ new exchange account', newAccountPh: 'Name of new account', assetsTitle: 'Assets', assetOk: 'linked', diff --git a/client/i18n/nl.js b/client/i18n/nl.js index 13504b3..29b3be2 100644 --- a/client/i18n/nl.js +++ b/client/i18n/nl.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:f025d672341c54d23ebad8e10876b424ac570cd500126582bf4b9c905f2cd672 +// Generated, do not edit. sha256:68408d2148a830c2e11f8761e94fa494e4d87a9e45166891d38c4b2464170782 export const nl = { app: { name: 'Atreides Assets' }, @@ -11,6 +11,8 @@ export const nl = { requestTooLarge: 'Het verzoek is te groot.', fileTooLarge: 'Het bestand is te groot.', invalidAmount: 'Ongeldige hoeveelheid.', + create: 'Aanmaken', + rename: 'Hernoemen', }, splash: { @@ -70,22 +72,15 @@ export const nl = { 'why_unknown-version': 'De versie van de app is niet te bepalen', why_licensed: 'Geldige licentie', cardTitle: 'Licentie', - cardFree: 'Deze installatie draait de gratis versie: onbeperkt in tijd, met een kleine ' - + 'administratie en zonder de koppelingen, de bronkeuze en de belastingpagina. Lezen en ' - + 'exporteren blijven altijd werken; er wordt nooit iets weggehaald.', - cardBuy: 'De betaalde versie heft die grenzen op. Hebt u een licentiebestand, zet het dan hieronder ' - + 'neer.', - cardFull: 'Deze installatie draait de volledige versie. Alle grenzen zijn opgeheven en elk ' - + 'onderdeel staat open.', - cardDevelop: 'Dit is een ontwikkelversie: onder 1.0.0 beperkt de app niets.', - cardFacts: 'De licentie is voor {buyer}, afgegeven op {issued} en geldig voor hoofdversie {from} ' - + 'tot en met {to}.', - cardOutOfRange: 'Deze app is versie {version} en valt buiten dat bereik.', + cardFree: 'Gratis versie: onbeperkt in tijd, met een kleine administratie. Er wordt nooit iets ' + + 'weggehaald.', + cardFull: 'Volledige versie: alle grenzen opgeheven.', + cardFor: 'Deze licentie is voor {npub}', + cardFacts: 'Afgegeven op {issued}, geldig voor hoofdversie {from} tot en met {to}.', cardProblem: 'Er staat een licentiebestand, maar de app kan er niets mee.', cardVersion: 'Versie {version}', signInTitle: 'Aanmelden', - signInIntro: 'Uw licentie hoort bij een nostr-sleutel. Meld u aan om de licenties bij die sleutel op ' - + 'te halen.', + signInIntro: 'Meld u aan met uw nostr-sleutel om te kopen of uw licentie op te halen.', signInLast: 'Laatst aangemeld als {npub}.', signInExtension: 'Met extensie', signInExtensionNone: 'Geen nostr-extensie gevonden in deze browser (zoals Alby of nos2x).', @@ -126,7 +121,6 @@ export const nl = { buyClosed: 'De verkoop is op dit moment gesloten.', buyAway: 'Atreides Services is nu niet bereikbaar, dus kopen kan op dit moment niet. Probeer het later ' + 'opnieuw.', - buySignInFirst: 'Meld u eerst aan: de licentie komt op uw sleutel te staan.', buyButton: 'Kopen', buyInvoice: 'Betaal deze invoice met een Lightning-wallet. Hij is geldig tot {time}.', buyOpenWallet: 'Openen in wallet', @@ -183,8 +177,7 @@ export const nl = { + 'ID-controle).', payNote: 'Stand van oktober 2026: controleer de voorwaarden bij de aanbieder.', nostrMore: 'Over nostr en uw sleutel', - signInKnown: 'Uw licentie staat op {npub}. Onderteken met die sleutel om licenties op te halen, te kopen ' - + 'of support te vragen; de npub alleen bewijst niet dat u het bent.', + signInKnown: 'Gebruik de sleutel waar deze licentie op staat.', infoNostrHead: 'Wat is nostr?', infoNostr: 'Nostr is een open protocol waarin uw identiteit een sleutelpaar is. De publieke sleutel ' + '(npub) is als een adres: die mag iedereen zien. De geheime sleutel (nsec) is als een wachtwoord dat ' @@ -211,17 +204,14 @@ export const nl = { + 'gemaakt, zodat het alleen terug te vinden is als u zich er zelf mee meldt.', name_fiatAccounts: 'Fiatrekeningen', name_assets: 'Assets naast valuta', - name_valuations: 'Balansen', - name_portfolios: 'Portefeuilles', + name_portfolios: "Portfolio's", featTitle: 'Wat de edities bieden', featFull: 'Volledig', featFree: 'Gratis', - featFreeOpen: 'Wat de gratis editie krijgt, ligt nog niet vast.', featNoShot: 'Nog geen schermafdruk van dit onderdeel.', featIncluded: 'Inbegrepen', featExcluded: 'Niet inbegrepen', featUndecided: 'Nog niet bepaald', - featPartial: 'deels', featPartialTitle: 'Een deel is inbegrepen', featGroup_overview: 'Overzicht en rapportage', featGroup_bitcoin: 'Bitcoin en Lightning', @@ -238,22 +228,19 @@ export const nl = { feat_balances: 'Balansen en reconcile', feat_ownMempool: 'Eigen mempool-node', feat_priceHistory: 'Prijsgeschiedenis', - feat_sourceChoice: 'Bronkeuze per asset', - feat_providerKeys: 'Eigen koersbronnen en API-sleutels', + feat_sourceChoice: 'Bronkeuze-matrix', + feat_providerKeys: 'Beheer van eigen integraties en API-sleutels', feat_signals: 'Bitcoin-signalen, grafieken en widget', feat_netshare: 'Widget netwerkaandeel', - feat_portfolios: 'Meerdere portefeuilles', + feat_portfolios: "Meerdere portfolio's", feat_ai: 'AI-koppeling (MCP)', + feat_accountMerge: 'Accounts samenvoegen', feat_import: 'Importeren en exporteren', feat_data: 'Data: de ruwe tabellen', feat_health: 'Gezondheid: controles op de administratie', feat_kiosk: 'De app in een eigen venster', feat_metals: 'Edelmetaal, munten en baren', unlimited: 'onbeperkt', - dropHere: 'Sleep het licentiebestand hierheen', - dropOr: 'of klik om er een te kiezen', - dropTooBig: 'Dat bestand is veel te groot voor een licentie. Het licentiebestand is een klein ' - + 'JSON-bestand van hooguit een paar regels.', installOk: 'Licentie opgeslagen. De app is nu de volledige versie.', installOkFuture: 'Licentie opgeslagen, maar hij geldt niet voor deze hoofdversie. De app blijft ' + 'voorlopig in de gratis stand.', @@ -331,14 +318,14 @@ export const nl = { nwcRelayRefusedNoReason: 'De relay weigert het verzoek en zegt niet waarom.', nwcDecryptFailed: 'Antwoord ontsleutelen mislukt: {reden}', kindMarket: 'Atreides Services', - usedByMarket: 'De eigen koersdienst, voor koersen, de licentie en support. Adres en token gelden voor de hele installatie, dus voor elke portefeuille. De app praat via de eigen server met de dienst; het token blijft server-side en komt nooit terug in de browser.', + usedByMarket: 'De eigen koersdienst, voor koersen, de licentie en support. Adres en token gelden voor de hele installatie, dus voor elk portfolio.', marketConfigure: 'Instellen', marketDialogTitle: 'Atreides Services instellen', marketTokenUnset: 'geen token', - marketTokenLicense: 'token van de licentie ({tier})', - marketTokenManual: 'eigen token', - marketTokenPending: 'de app vraagt een token aan met de licentie', - marketTokenNoLicense: 'geen licentie om een token mee aan te vragen', + marketTokenLicense: 'Token van de licentie ({tier})', + marketTokenManual: 'Eigen token', + marketTokenPending: 'De app vraagt een token aan met de licentie', + marketTokenNoLicense: 'Geen licentie om een token mee aan te vragen', marketOverrideUrl: 'ontwikkeladres', marketTestOk: '{app} {version} · {n} instrumenten', marketSpot: 'Wat de app uit de dienst haalt', @@ -391,7 +378,7 @@ export const nl = { system: 'Systeem', home: 'Dashboard', settings: 'Instellingen', - portfolios: 'Portefeuilles', + portfolios: "Portfolio's", import: 'Importeren en exporteren', data: 'Data', health: 'Gezondheid', @@ -435,14 +422,14 @@ export const nl = { addNoFit: 'Hier is te weinig ruimte voor de widgets die nog kunnen', addNone: 'Alles is al toegevoegd', profile: 'Indeling', - profileNew: 'Nieuwe indeling…', + profileNew: 'Nieuwe indeling', profileNewPrompt: 'Naam van de nieuwe indeling', - profileRename: 'Naam wijzigen…', + profileRename: 'Naam wijzigen', profileRenamePrompt: 'Nieuwe naam voor deze indeling', - profileDelete: 'Deze indeling verwijderen…', + profileDelete: 'Deze indeling verwijderen', profileDeleteConfirm: 'Deze indeling en al zijn widgets verwijderen? De andere indelingen blijven staan.', profileSystemHint: 'Standaard kan niet hernoemd worden.', - profileRestart: 'Standaard opnieuw beginnen…', + profileRestart: 'Standaard opnieuw beginnen', profileRestartConfirm: 'Standaard opnieuw beginnen? Wat je zelf hebt neergezet gaat weg en de standaardindeling komt ervoor in de plaats.', nameRequired: 'Een indeling heeft een naam nodig.', unknownProfile: 'Indeling #{id} bestaat niet.', @@ -598,12 +585,12 @@ export const nl = { kindAccount: 'Nieuw account', kindAccountDelete: 'Account verwijderen', kindValuation: 'Balans', - kindPortfolio: 'Nieuwe portefeuille', + kindPortfolio: 'Nieuw portfolio', portfolioIn: 'in', - portfolioNote: 'Leeg, en zonder sleutels of data uit deze administratie. Hij wordt niet geopend: ' - + 'wisselen doe je zelf op Systeem → Portefeuilles, en dat is een herstart van de app.', + portfolioNote: 'Leeg, en zonder sleutels of data uit deze administratie. Het wordt niet geopend: ' + + "wisselen doe je zelf op Systeem → Portfolio's, en dat is een herstart van de app.", kindPreference: 'Instelling wijzigen', - preferenceNote: 'Deze instelling geldt voor deze portefeuille en verandert alleen de weergave of ' + preferenceNote: 'Deze instelling geldt voor dit portfolio en verandert alleen de weergave of ' + 'een interval, niet de administratie zelf.', preferenceCurrent: 'nu', preferenceOn: 'aan', @@ -611,7 +598,7 @@ export const nl = { kindSourceChoice: 'Bronkeuze', sourceFirst: 'als eerste', sourceRemove: 'eruit halen', - sourceChoiceNote: 'De keten zoals hij nu staat zie je op Integraties, Bronkeuze, of op het tabblad Bron van Prijsgeschiedenis.', + sourceChoiceNote: 'De keten zoals hij nu staat zie je op Integraties, Bronkeuze, of op het tabblad Koersen van Prijsgeschiedenis.', unknownKind: 'Onbekend soort voorstel', ledger: 'grootboek', diff: 'verschil', @@ -669,7 +656,7 @@ export const nl = { bookTitle: 'Reservering boeken', otherTo: 'Naar', otherFrom: 'Van', - outside: 'Buiten de portefeuille', + outside: 'Buiten het portfolio', fill: 'Vul een datum, een asset en een bedrag groter dan nul in.', confirmSettle: 'Deze reservering afhandelen zonder boeking? Hij verdwijnt dan.', confirmDelete: 'Deze reservering verwijderen?', @@ -937,7 +924,7 @@ export const nl = { finish: 'Inrichten', persona_bitcoin: 'Alleen bitcoin', persona_broad: 'Breder', - rerun: 'Inrichten…', + rerun: 'Inrichten', }, notes: { @@ -1023,8 +1010,8 @@ export const nl = { resultSignsNegative: 'Alleen negatief', resultSignsBoth: 'Negatief en positief', resultSignsHint: 'Geldt voor resultaten en rendementen in groen of rood. Bij "Geen" zegt alleen de kleur of het winst of verlies is. Zonder kleur staat het teken er altijd.', - persona: 'Portefeuille gaat over', - personaHint: 'Breder verbergt Signalen & Grafieken en de bitcoinwidgets uit de keuze voor het dashboard. Per portefeuille; boekingen en assets veranderen niet.', + persona: 'Portfolio gaat over', + personaHint: 'Breder verbergt Signalen & Grafieken en de bitcoinwidgets uit de keuze voor het dashboard. Per portfolio; boekingen en assets veranderen niet.', kiosk: 'Openen in', kioskWindow: 'Browser', kioskFull: 'Eigen venster', @@ -1076,13 +1063,13 @@ export const nl = { writeOn: 'Aan: een AI mag gegevens toevoegen of wijzigen, altijd via een voorstel dat u accordeert.', writeOff: 'Uit: elk verzoek om iets te wijzigen wordt geweigerd.', rawLabel: 'Onbewerkt delen', - rawOn: 'Aan: een AI ziet de echte namen en bedragen van deze portefeuille.', + rawOn: 'Aan: een AI ziet de echte namen en bedragen van dit portfolio.', rawOff: 'Uit: een AI ziet verwijzingen en marges in plaats van namen en bedragen.', - rawHint: 'Alleen aanzetten als deze portefeuille geen echte gegevens bevat. De app kan dat niet ' - + 'vaststellen; dat weet alleen u. Let op: een kopie van een portefeuille bevat de gegevens van ' + rawHint: 'Alleen aanzetten als dit portfolio geen echte gegevens bevat. De app kan dat niet ' + + 'vaststellen; dat weet alleen u. Let op: een kopie van een portfolio bevat de gegevens van ' + 'het origineel.', rawConfirm: 'Onbewerkt delen aanzetten voor "{naam}"? Een gekoppelde AI ziet daarna de echte namen ' - + 'en bedragen van deze portefeuille in plaats van verwijzingen en marges. Doe dit alleen als hier ' + + 'en bedragen van dit portfolio in plaats van verwijzingen en marges. Doe dit alleen als hier ' + 'geen echte gegevens in staan.', precisionTitle: 'Hoe precies een AI de cijfers ziet', precisionIntro: 'Aan betekent marges in plaats van exacte getallen, en dat is de stand waarin de ' @@ -1103,7 +1090,7 @@ export const nl = { precisionCombo: 'Let op: staan "Percentages" en "Totalen" allebei uit, dan laat een AI-antwoord de ' + 'verdeling over uw assets wég. Samen leggen die twee de waarde per asset vast, terwijl de ' + 'bedragen per regel juist in marges staan.', - scope: 'Deze instellingen gelden alleen voor de portefeuille die nu open is: {naam}.', + scope: 'Deze instellingen gelden alleen voor het portfolio dat nu open is: {naam}.', revoke: 'Een recht dat u geeft, kunt u hier altijd weer intrekken: zet de schuif uit en het geldt ' + 'vanaf de volgende aanroep, ook voor een AI-programma dat al draait. Herstarten is niet nodig. ' + 'Wat al is goedgekeurd, blijft staan; intrekken gaat over wat een AI hierna nog mag.', @@ -1252,9 +1239,7 @@ export const nl = { fiatHint: 'Traditionele munteenheid', btcHint: 'Basiseenheid · max 21 mln', hierarchy: 'Eenheden hiërarchie', - satNote: 'De satoshi is de kleinste on-chain eenheid. De millisatoshi bestaat alleen op het Lightning Network.', - footer: 'Live koers via de gekozen koersbron', - }, + satNote: 'De satoshi is de kleinste on-chain eenheid. De millisatoshi bestaat alleen op het Lightning Network.', }, labels: { title: 'Labels', @@ -1317,6 +1302,7 @@ export const nl = { merge: 'Samenvoegen', mergeTitle: 'Twee accounts samenvoegen tot één', mergeNeedTwo: 'Je hebt minstens twee accounts nodig om samen te voegen.', + mergePaid: 'Accounts samenvoegen hoort bij de volledige editie.', mergePick: '(kies een account)', mergeKeep: 'Behouden account', mergeDrop: 'Opheffen account', @@ -1497,7 +1483,7 @@ export const nl = { buitenBox3: 'Buiten het overzicht gehouden (telt wél als vermogen):', emptyColsNote: 'Weggelaten peildata omdat er niets stond: {jaren}. In het resultaat per jaar blijven ' + 'ze de beginwaarde van dat jaar.', - startYearNote: 'Deze administratie begint in {eerste} en wordt getoond vanaf peildatum 1 januari {start}. De standen tellen alles daarvóór gewoon mee; er ontbreken alleen kolommen. Het startjaar staat op Systeem → Portefeuilles.', + startYearNote: 'Deze administratie begint in {eerste} en wordt getoond vanaf peildatum 1 januari {start}. De standen tellen alles daarvóór gewoon mee; er ontbreken alleen kolommen. Het startjaar staat op Systeem → Portfolio\'s.', aangifteNote: 'Kengetallen per jaar over het vermogen dat in deze app staat: crypto, edelmetaal en de accounts die je hier bijhoudt. Rendement = eindwaarde - beginwaarde - aankopen + verkopen - wat uit balansen kwam. "Huidige waarde" is het lopende jaar t/m nu; een jaar krijgt een eigen kolom zodra het is afgerond. De kop van een jaarkolom is de peildatum waarop dat jaar eindigt, zodat de kolommen uitlijnen met de tabel hierboven: de Eindwaarde hier is dezelfde peildatum-kolom daar, en de Beginwaarde is de kolom rechts ernaast. Klik een bedrag om het (afgerond op hele eenheden) te kopiëren. Deze app rekent geen belasting uit: dit zijn de kengetallen die een aangifte doorgaans vraagt; tarief en vrijstellingen verschillen per land.', kgRendement: 'Rendement', kgUitBalansen: 'Uit balansen (niet geboekt)', @@ -1555,14 +1541,12 @@ export const nl = { reservation: 'reservering', interestDue: 'rente verwacht', }, - hintActivity: 'De lijn bovenaan (alle getoonde accounts), onderaan een kaart en in het accountvenster is de activiteit vanaf het startjaar van de portefeuille: een piek omhoog is een dag waarop er iets binnenkwam, een dal een dag waarop er iets uitging; de hoogte volgt het aantal boekingen. Streepjes zijn balansen, rente-afspraken, verwachte rentebijschrijvingen, reserveringen (een vierkantje) en wijzigingen aan het account; de lijn loopt door tot de laatste daarvan, ook als die in de toekomst ligt. In het accountvenster opent een klik op een dag die boeking of reservering.', + hintActivity: 'De lijn bovenaan (alle getoonde accounts), onderaan een kaart en in het accountvenster is de activiteit vanaf het startjaar van het portfolio: een piek omhoog is een dag waarop er iets binnenkwam, een dal een dag waarop er iets uitging; de hoogte volgt het aantal boekingen. Streepjes zijn balansen, rente-afspraken, verwachte rentebijschrijvingen, reserveringen (een vierkantje) en wijzigingen aan het account; de lijn loopt door tot de laatste daarvan, ook als die in de toekomst ligt. In het accountvenster opent een klik op een dag die boeking of reservering.', hintInterest: 'Onder het saldo: de lopende rente-afspraken van het account en hoe vaak er rente of beloning is geboekt.', hintCapture: 'De knop "Saldo vastleggen" staat standaard alleen bij geld. Per asset zet je hem aan of uit op Systeem, tab Assets, kolom "Saldo vastleggen".', }, valuations: { - maxFree: 'De gratis versie houdt het op {max} balans. Met een licentie vervalt die grens; ' - + 'er wordt intussen niets weggehaald.', title: 'Balansen', needAsset: 'Maak eerst een asset aan of migreer de data op het overzicht.', colDate: 'Peildatum', @@ -1593,8 +1577,8 @@ export const nl = { acceptedHint: 'Aanvaard verschil, klik om terug te draaien:', bookTitle: 'Verschil boeken', bookAsSuffix: 'boeken als', - bookAsSell: 'Verkoop (ging uit je portefeuille)', - bookAsBuy: 'Aankoop (kwam je portefeuille in)', + bookAsSell: 'Verkoop (ging uit je portfolio)', + bookAsBuy: 'Aankoop (kwam je portfolio in)', bookAsTransferTo: 'Verplaatsing naar', bookAsTransferFrom: 'Verplaatsing van', bookAsFeeOn: 'Kosten bij {soort} van {datum}', @@ -2003,7 +1987,6 @@ export const nl = { provToGaps: 'Naar dit gat onder Gaten', provSpotNote: 'tot {pct} naast de slotkoers', provCarriedNote: 'tot {n} dagen oud', - tabSource: 'Bron', diagCard_noCoverage: 'Geen integratie levert koersen', diagCard_allInactive: '{namen} staat uit', diagCard_noChoice: 'Geen bronkeuze', @@ -2156,77 +2139,91 @@ export const nl = { }, portfolios: { - maxFree: 'De gratis versie houdt het op {max} portefeuille. Met een licentie vervalt die grens; ' + maxFree: 'De gratis versie houdt het op {max} portfolio. Met een licentie vervalt die grens; ' + 'er wordt intussen niets weggehaald.', - title: 'Portefeuilles', + title: "Portfolio's", switchFailed: 'Wisselen is niet gelukt.', - nameRequired: 'Een portefeuille moet een naam hebben.', - nameTooLong: 'Een portefeuillenaam is hoogstens {max} tekens lang.', + nameRequired: 'Een portfolio moet een naam hebben.', + nameTooLong: 'Een portfolionaam is hoogstens {max} tekens lang.', nameIsDirRef: '"{naam}" is geen naam maar een verwijzing naar een map.', - nameForbiddenChars: 'Een portefeuillenaam mag geen van deze tekens bevatten: < > : " / \\ | ? *', - nameTrailing: 'Een portefeuillenaam mag niet op een spatie of een punt eindigen.', - nameLeadingSpace: 'Een portefeuillenaam mag niet met een spatie beginnen.', + nameForbiddenChars: 'Een portfolionaam mag geen van deze tekens bevatten: < > : " / \\ | ? *', + nameTrailing: 'Een portfolionaam mag niet op een spatie of een punt eindigen.', + nameLeadingSpace: 'Een portfolionaam mag niet met een spatie beginnen.', nameReserved: '"{naam}" is een gereserveerde naam in Windows en kan geen map worden.', nameTaken: '"{naam}" is een naam die de app zelf gebruikt; kies een andere.', - activeCannotRename: '"{naam}" is de portefeuille die nu open is en kan niet hernoemd worden. Wissel eerst naar een andere portefeuille; de app start daarbij opnieuw.', - activeCannotArchive: '"{naam}" is de portefeuille die nu open is en kan niet weggegooid worden. Wissel eerst naar een andere portefeuille; de app start daarbij opnieuw.', - unknownPortfolio: 'Er is geen portefeuille "{naam}".', - nameInUse: 'Er is al een portefeuille "{naam}"; namen die alleen in hoofdletters of in schrijfwijze verschillen tellen als dezelfde.', + activeCannotRename: '"{naam}" is het portfolio dat nu open is en kan niet hernoemd worden. Wissel eerst naar een ander portfolio; de app start daarbij opnieuw.', + activeCannotArchive: '"{naam}" is het portfolio dat nu open is en kan niet weggegooid worden. Wissel eerst naar een ander portfolio; de app start daarbij opnieuw.', + unknownPortfolio: 'Er is geen portfolio "{naam}".', + nameInUse: 'Er is al een portfolio "{naam}"; namen die alleen in hoofdletters of in schrijfwijze verschillen tellen als dezelfde.', archiveFull: 'Het archief zit vol met mappen die "{naam}" heten; ruim er eerst een paar op.', notInArchive: 'Er staat geen "{naam}" in het archief.', passwordRequired: 'Vul een wachtwoord in.', - intro: 'Elke portefeuille is een eigen administratie: een eigen database én eigen geheimen, in een eigen map. Er is er altijd precies één open.', + intro: 'Elk portfolio is een eigen administratie: een eigen database én eigen geheimen, in een eigen map. Er is er altijd precies één open; de kaart daarvan staat bovenaan.', openNow: 'Nu open', - activate: 'Openen…', + activate: 'Openen', activateConfirm: 'Overschakelen naar "{naam}"? De app start daarvoor opnieuw op.', activateWaiting: 'De app start opnieuw…', activateNoSupervisor: 'De keuze is vastgelegd, maar deze app is gestart zonder de supervisor (npm run start:server). Sluit de app en start hem opnieuw om in "{naam}" te werken.', - create: 'Nieuwe portefeuille…', + create: 'Nieuw portfolio', + createConfirm: 'Aanmaken', createName: 'Naam', createNameHint: 'De naam wordt de mapnaam op schijf.', createCurrency: 'Rekenvaluta', - createDone: 'Portefeuille "{naam}" aangemaakt.', - copy: 'Kopiëren…', + createDone: 'Portfolio "{naam}" aangemaakt.', + copy: 'Kopiëren', copyTitle: 'Kopie van "{naam}"', copyName: 'Naam van de kopie', copyConfirm: 'Kopiëren', - copyDone: 'Portefeuille "{naam}" aangemaakt als kopie van "{bron}".', - createHint: 'Nieuwe portefeuille geeft een verse administratie zonder verbindingen. Kopiëren doe je per portefeuille in de lijst; een kopie neemt de database én de geheimen samen mee, want een geheim hoort bij een rij en klopt alleen bij die database.', - createCurrencyHint: 'De rekenvaluta is de munt waarin de portefeuille rekent en alle bedragen toont. Je kiest hem bij een nieuwe portefeuille en daarna ligt hij vast; een kopie houdt de munt van het origineel.', - rename: 'Hernoemen…', + copyDone: 'Portfolio "{naam}" aangemaakt als kopie van "{bron}".', + createHint: 'Nieuw portfolio geeft een verse administratie zonder verbindingen. Kopiëren doe je via het menu (…) op de kaart; een kopie neemt de database én de geheimen samen mee, want een geheim hoort bij een rij en klopt alleen bij die database.', + createCurrencyHint: 'De rekenvaluta is de munt waarin het portfolio rekent en alle bedragen toont. Je kiest hem bij een nieuw portfolio en daarna ligt hij vast; een kopie houdt de munt van het origineel.', + rename: 'Hernoemen', renameTo: 'Nieuwe naam', renameDone: 'Hernoemd naar "{naam}".', - renameActive: 'De portefeuille die nu open is, kan niet hernoemd worden: zijn database staat open. Schakel eerst over naar een andere.', - remove: 'Verwijderen…', - removeConfirm: 'Portefeuille "{naam}" verwijderen? De map verhuist naar het archief; er wordt niets gewist. Typ ter bevestiging de naam over.', + renameActive: 'Het portfolio dat nu open is, kan niet hernoemd worden: zijn database staat open. Schakel eerst over naar een andere.', + remove: 'Verwijderen', + removeConfirm: 'Portfolio "{naam}" verwijderen? De map verhuist naar het archief; er wordt niets gewist. Typ ter bevestiging de naam over.', removeTypeLabel: 'Typ de naam', removeMismatch: 'Dat is niet de naam; er is niets gewijzigd.', removeDone: '"{naam}" staat nu in het archief.', - empty: 'Er is nog geen andere portefeuille.', noDatabase: 'nog geen database', - lastUsed: 'laatst gebruikt', never: 'nog niet gebruikt', + cardSince: '{munt}, sinds {jaar}', + factAssets: 'Assets in gebruik', + factAccounts: 'Actieve accounts', + factEvents: 'Boekingen', + factValuations: 'Balansen', + factLastUsed: 'Laatst gebruikt', + factBackup: 'Laatste back-up', + backupNever: 'nog nooit', + more: 'Meer acties', + backupTitle: 'Back-up', + backupLateHint: 'De laatste back-up kleurt oranje als hij ouder is dan {dagen} dagen of er nog nooit een is gemaakt. Terugzetten en leeg beginnen staan in het menu (…) van het portfolio dat open is en gelden alleen daarvoor.', + archiveCount: 'Archief ({n})', + demoBadge: 'Voorbeeld', + demoHint: 'Demo is een voorbeeldadministratie met bitcoin, een exchange, een eigen wallet en een bankrekening, gevuld over de afgelopen tweeënhalf jaar. Hij telt niet mee voor de grens van de gratis editie. Openen is een herstart; terug naar je eigen portfolio ook.', archiveTitle: 'Archief', - archiveIntro: 'Verwijderde portefeuilles staan hier. Ze tellen nergens meer mee, maar de bestanden zijn er nog.', - archiveEmpty: 'Het archief is leeg.', - purge: 'Definitief verwijderen…', + archiveIntro: "Verwijderde portfolio's staan hier. Ze tellen nergens meer mee, maar de bestanden zijn er nog.", + purge: 'Definitief verwijderen', purgeConfirm: 'De map van "{naam}" en alles erin definitief verwijderen? Database, geheimen en historie zijn daarna weg. Dit kan niet ongedaan gemaakt worden. Typ ter bevestiging de naam over.', purgeDone: '"{naam}" is definitief verwijderd.', - settingsTitle: 'Instellingen van deze portefeuille', + settingsButton: 'Instellingen', + settingsOf: 'Instellingen van {naam}', hintTitle: 'Wat zie je hier', - authTitle: 'Toegang tot deze portefeuille', - authNone: 'Geen wachtwoord ingesteld. De app is daardoor alleen vanaf deze machine bereikbaar.', + authTitle: 'Toegang tot dit portfolio', + authNone: 'Geen wachtwoord ingesteld.', authSet: 'Er is een wachtwoord ingesteld.', authEnv: 'Ingesteld via de omgevingsvariabele ASSETAPP_PASSWORD. Zolang die er staat, wint dat van wat je hier invult.', - authChange: 'Instellen of wijzigen…', - authClear: 'Leegmaken…', + authChange: 'Wachtwoord instellen', + authSave: 'Opslaan', + authClear: 'Leegmaken', authPassword: 'Wachtwoord', - authClearConfirm: 'Het wachtwoord van deze portefeuille weghalen? Daarna is de app alleen nog vanaf deze machine bereikbaar.', + authClearConfirm: 'Het wachtwoord van dit portfolio weghalen? Daarna is de app alleen nog vanaf deze machine bereikbaar.', authDone: 'Opgeslagen. Het geldt vanaf de volgende keer dat de app start.', authClearedDone: 'Weggehaald. Het geldt vanaf de volgende keer dat de app start.', authLogout: 'Uitloggen', authLogoutConfirm: 'Uitloggen? Je moet het wachtwoord opnieuw invoeren om verder te kunnen.', - authHint: 'Van een ander apparaat erbij kunnen vergt een certificaat én inloggegevens. Het certificaat hoort bij deze installatie; de inloggegevens bij deze portefeuille.', + authHint: 'Zonder wachtwoord is de app alleen vanaf deze machine bereikbaar. Van een ander apparaat erbij kunnen vergt een certificaat én inloggegevens. Het certificaat hoort bij deze installatie; de inloggegevens bij dit portfolio.', startYearTitle: 'Startjaar van deze administratie', startYearLabel: 'Begin overzichten bij', startYearAuto: 'Automatisch (vanaf de eerste boeking)', @@ -2244,7 +2241,6 @@ export const nl = { }, dbfile: { - title: 'De hele administratie', passTooShort: 'Kies een wachtwoord van minstens 8 tekens voor de back-up.', notABackup: 'Dit bestand is geen AssetApp-back-up (te kort).', notABackupUseRestore: 'Dit bestand is geen AssetApp-back-up. Een losse .sqlite zet je terug met "Terugzetten".', @@ -2265,20 +2261,21 @@ export const nl = { versionNewerThanApp: 'Deze database is versie {versie} en dus nieuwer dan de app ({app}). Werk de app bij voordat je hem terugzet.', emptyFile: 'Leeg bestand ontvangen.', notSqlite: 'Dit is geen SQLite-bestand (de bestandskop klopt niet).', - backup: 'Back-up maken…', + backup: 'Back-up', + backupConfirm: 'Back-up maken', backupPass: 'Wachtwoord voor de back-up', backupPassAgain: 'Wachtwoord herhalen', backupPassMismatch: 'De twee wachtwoorden zijn niet gelijk.', backupDone: 'Back-up gemaakt. Bewaar het wachtwoord goed: zonder wachtwoord is de back-up niet terug te zetten.', export: 'Database exporteren', - import: 'Terugzetten…', - confirmRestoreBackup: 'Deze back-up terugzetten? Dat vervangt de database ÉN de geheimen (secrets.json in de map van deze portefeuille). Van allebei blijft de vorige versie als .previous staan.', + import: 'Terugzetten', + confirmRestoreBackup: 'Deze back-up terugzetten? Dat vervangt de database ÉN de geheimen (secrets.json in de map van dit portfolio). Van allebei blijft de vorige versie als .previous staan.', restoredSecrets: 'Geheimen meeteruggezet:', confirmImport: 'De huidige database vervangen door dit bestand? De vorige blijft als .previous naast het databasebestand staan.', importDone: 'Database teruggezet', importOrphans: 'Let op, verweesde verwijzingen gevonden:', hint: 'De back-up bevat de database én de geheimen, versleuteld. De export is alleen de database: genoeg om te lezen, niet genoeg om alles terug te zetten.', - fresh: 'Leeg beginnen…', + fresh: 'Leeg beginnen', confirmFresh: 'Met een lege administratie beginnen? Er komt een verse database in gebruik; de huidige blijft als .previous naast het databasebestand staan. Maak eerst een back-up als je hier ooit nog bij wilt.', freshWord: 'leeg', freshTypeLabel: 'Typ ter bevestiging het woord', @@ -2301,7 +2298,7 @@ export const nl = { nSkipped: 'overgeslagen', account: 'Account (exchange) voor deze import', chooseAccount: '(kies account)', - newAccount: '+ nieuw exchange-account…', + newAccount: '+ nieuw exchange-account', newAccountPh: 'Naam nieuw account', assetsTitle: 'Assets', assetOk: 'gekoppeld', diff --git a/client/pages/accounts.js b/client/pages/accounts.js index 2d451d5..4018062 100644 --- a/client/pages/accounts.js +++ b/client/pages/accounts.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:9b4688b90b1d72ebe6c49262c3d23557d132d9066d8379a911157bbf3dae8ae8 +// Generated, do not edit. sha256:aff17b8d5d572bccce031cf1d513314ef3a7957125c4d0ff5f5851fdb069432a import { mergeCheck, mergeAccounts } from '../data/accounts-merge.js'; import { listAccounts, listSelectableAccounts, createAccount, updateAccount, deleteAccount } from '../data/accounts.js'; import { listConnections } from '../data/connections.js'; @@ -121,7 +121,8 @@ async function buildTable(el) { if (!(await dialog.confirm({ message: t('accounts.confirmDelete'), danger: true }))) return; try { await deleteAccount(id); reload(); } catch (e) { dialog.alert({ title: t('dialog.error'), message: e.message }); } }, - toolbarActions: [{ id: 'merge', icon: MERGE, label: t('accounts.merge'), title: t('accounts.mergeTitle') }], + toolbarActions: locked('accountMerge') ? [] + : [{ id: 'merge', icon: MERGE, label: t('accounts.merge'), title: t('accounts.mergeTitle') }], onToolbarAction: (id, anchor) => { if (id === 'merge') openMergeMenu(anchor); }, rowExpansion: () => '', onExpansionMount: (a, host) => mountExpansion(host, a.id), diff --git a/client/pages/connections.js b/client/pages/connections.js index ced6cdd..61c17eb 100644 --- a/client/pages/connections.js +++ b/client/pages/connections.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:1f57286ac82ef2aadfb0cdfa809fcb1f771cf74bba815b7e579bbb106a986dd4 +// Generated, do not edit. sha256:b2711d1eac7d201be0c0b5dbcc1d76495b068fd4828670afac37d02cd756c98f import { t } from '../i18n/index.js'; import { listConnections, saveConnection, setActiveConnection, deleteConnection, recordConnectionStatus } from '../data/connections.js'; import { localDateTimeNl } from '../../shared/time.js'; @@ -171,9 +171,9 @@ async function marketFrameHtml() {
Atreides Services
${url ? `
${esc(url)}
` : ''} +
${esc(stand)}
-
${esc(stand)}
${lastFailure}
diff --git a/client/pages/conversion-bitcoin.js b/client/pages/conversion-bitcoin.js index c546412..4b79698 100644 --- a/client/pages/conversion-bitcoin.js +++ b/client/pages/conversion-bitcoin.js @@ -1,9 +1,10 @@ -// Generated, do not edit. sha256:1c9c0ff79637180d3780a7e1dd1e59dbb03533899d9a66468c9cdf709d9ee0fe +// Generated, do not edit. sha256:29c2ecea7f7203cf2a789f574d5f90a158b4c2ec943bae44c680cc1e970776b5 import { t, localeTag } from '../i18n/index.js'; import { listAssets } from '../data/assets.js'; import { liveSpotFor, basePriceOf } from '../price/providers.js'; import { fmtMoney, fmtInt, currencySymbol, currencyName, parseLocaleNumber } from '../ui/format.js'; import { baseCurrency } from '../app-settings.js'; +import { setPageHint } from '../ui/page-hint.js'; const TO_BTC = { btc: 1, mbtc: 1e-3, bit: 1e-6, sat: 1e-8, msat: 1e-11 }; const UNITS = ['fiat', 'btc', 'mbtc', 'bit', 'sat', 'msat']; @@ -28,35 +29,27 @@ function formatUnit(unit, value) { export async function render(el) { const n = fmtInt; el.innerHTML = ` - -
-
+
+
${t('conversion.btcRate')}
€ -
${t('conversion.loading')}
-
- -
- ${field('fiat', t('conversion.fiat'), '€ EUR', t('conversion.fiatHint'), true)} - ${field('btc', 'Bitcoin', '₿ BTC', t('conversion.btcHint'))} - ${field('mbtc', 'Millibitcoin', 'mBTC', `1 BTC = ${n(1e3)} mBTC`)} - ${field('bit', 'Bit (µBTC)', 'bit', `1 BTC = ${n(1e6)} bits`)} - ${field('sat', 'Satoshi', 'sat', `1 BTC = ${n(1e8)} sats`)} - ${field('msat', 'Millisatoshi', 'msat', `1 sat = ${n(1e3)} msats · Lightning`)} -
- -
-
${t('conversion.hierarchy')}
-
- 1 BTC = ${n(1e3)} mBTC = ${n(1e6)} bits = ${n(1e8)} sats = ${n(1e11)} msats
- 1 mBTC = ${n(1e3)} bits = ${n(1e5)} sats
- 1 bit = 100 sats · 1 sat = ${n(1e3)} msats +
+ ${field('fiat', t('conversion.fiat'), '€ EUR', t('conversion.fiatHint'), true)} + ${field('btc', 'Bitcoin', '₿ BTC', t('conversion.btcHint'))} + ${field('mbtc', 'Millibitcoin', 'mBTC', `1 BTC = ${n(1e3)} mBTC`)} + ${field('bit', 'Bit (µBTC)', 'bit', `1 BTC = ${n(1e6)} bits`)} + ${field('sat', 'Satoshi', 'sat', `1 BTC = ${n(1e8)} sats`)} + ${field('msat', 'Millisatoshi', 'msat', `1 sat = ${n(1e3)} msats · Lightning`)}
-
${t('conversion.satNote')}
-
- - `; +
`; + setPageHint(el, { title: t('conversion.hierarchy'), rows: [ + `1 BTC = ${n(1e3)} mBTC = ${n(1e6)} bits = ${n(1e8)} sats = ${n(1e11)} msats`, + `1 mBTC = ${n(1e3)} bits = ${n(1e5)} sats`, + `1 bit = 100 sats · 1 sat = ${n(1e3)} msats`, + t('conversion.satNote'), + ] }); const q = id => el.querySelector('#' + id); const currency = baseCurrency(); diff --git a/client/pages/db-file.js b/client/pages/db-file.js new file mode 100644 index 0000000..c093138 --- /dev/null +++ b/client/pages/db-file.js @@ -0,0 +1,115 @@ +// Generated, do not edit. sha256:8e7f997881d1fd01e18e1023544e1df65cb2a48e77ba25495de5fe5ba3785bef +import { setAppSetting } from '../app-settings.js'; +import { t } from '../i18n/index.js'; +import { serverFoutTekst } from '../data/_rpc.js'; +import * as dialog from '../ui/dialog.js'; + +export async function backupDb() { + const res = await dialog.form({ + title: t('dbfile.backup'), + fields: [{ key: 'w1', label: t('dbfile.backupPass'), type: 'password' }, + { key: 'w2', label: t('dbfile.backupPassAgain'), type: 'password' }], + confirmLabel: t('dbfile.backupConfirm'), + }); + if (!res) return false; + if (res.w1 !== res.w2) { dialog.alert({ title: t('dialog.error'), message: t('dbfile.backupPassMismatch') }); return false; } + try { + const r = await fetch('/api/db/backup', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ passphrase: res.w1 }), + }); + if (!r.ok) throw new Error(serverFoutTekst(await r.json().catch(() => null)) || `HTTP ${r.status}`); + const blob = await r.blob(); + const naam = (r.headers.get('Content-Disposition') || '').match(/filename="([^"]+)"/)?.[1] || 'assetapp.assetbak'; + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; a.download = naam; a.click(); + URL.revokeObjectURL(url); + await stempelBackup(); + await dialog.alert({ message: t('dbfile.backupDone') }); + return true; + } catch (err) { + dialog.alert({ title: t('dialog.error'), message: err.message }); + return false; + } +} + +export async function exportDb() { + const a = document.createElement('a'); + a.href = '/api/db/export'; + a.download = ''; + a.click(); + await stempelBackup(); +} + +export function restoreDb(onChanged = () => {}) { + const fileInput = document.createElement('input'); + fileInput.type = 'file'; + fileInput.accept = '.assetbak,.sqlite,.db'; + fileInput.onchange = async () => { + const file = fileInput.files[0]; + if (!file) return; + try { + const kop = new Uint8Array(await file.slice(0, 15).arrayBuffer()); + const isBackup = new TextDecoder('latin1').decode(kop) === 'ASSETAPP-BACKUP'; + + if (!(await dialog.confirm({ + message: isBackup ? t('dbfile.confirmRestoreBackup') : t('dbfile.confirmImport'), danger: true, + }))) return; + + const headers = { 'Content-Type': 'application/octet-stream' }; + if (isBackup) { + const res = await dialog.form({ + title: t('dbfile.import'), + fields: [{ key: 'w', label: t('dbfile.backupPass'), type: 'password' }], + confirmLabel: t('dbfile.import'), + }); + if (!res) return; + headers['X-Backup-Passphrase'] = res.w; + } + + const res = await fetch('/api/db/import', { method: 'POST', headers, body: await file.arrayBuffer() }); + const json = await res.json().catch(() => null); + if (!res.ok) throw new Error(serverFoutTekst(json) || `HTTP ${res.status}`); + + const regels = [`${t('dbfile.importDone')} (versie ${json.versie}).`]; + if (json.wezen) regels.push(`${t('dbfile.importOrphans')} ${json.wezen}`); + regels.push(json.versleuteld ? `${t('dbfile.restoredSecrets')} ${json.geheimen}` : json.geheimenWaarschuwing); + dialog.alert({ message: regels.join('\n\n') }); + onChanged(); + } catch (err) { + dialog.alert({ title: t('dialog.error'), message: err.message }); + } + }; + fileInput.click(); +} + +export async function startFresh(onChanged = () => {}) { + if (!(await dialog.confirm({ message: t('dbfile.confirmFresh'), danger: true }))) return; + const woord = t('dbfile.freshWord'); + const res = await dialog.form({ + title: t('dbfile.fresh'), + fields: [{ key: 'w', label: `${t('dbfile.freshTypeLabel')} ${woord}`, type: 'text' }], + confirmLabel: t('dbfile.fresh'), + }); + if (!res) return; + if ((res.w || '').trim().toLowerCase() !== woord.toLowerCase()) { + dialog.alert({ title: t('dialog.error'), message: t('dbfile.freshWordMismatch') }); + return; + } + try { + const r = await fetch('/api/db/fresh', { method: 'POST' }); + const json = await r.json().catch(() => null); + if (!r.ok) throw new Error(serverFoutTekst(json) || `HTTP ${r.status}`); + dialog.alert({ message: `${t('dbfile.freshDone')} (versie ${json.versie}).\n\n${json.geheimenWaarschuwing}` }); + onChanged(); + } catch (err) { + dialog.alert({ title: t('dialog.error'), message: err.message }); + } +} + +async function stempelBackup() { + try { await setAppSetting('last_backup_at', new Date().toISOString()); } catch { } + document.dispatchEvent(new CustomEvent('providers-changed')); +} diff --git a/client/pages/event-accounts.js b/client/pages/event-accounts.js index 96ff1a2..7138a16 100644 --- a/client/pages/event-accounts.js +++ b/client/pages/event-accounts.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:aff33ec09f0738c89d055fc48911d73d2e952b3818493f0f70824b837ab7c4bf +// Generated, do not edit. sha256:ae28972ed451b65f2e773094a56cc2c886f8928f30dfae76134014f65aa7c8e8 import { listAccounts } from '../data/accounts.js'; import { listAssets } from '../data/assets.js'; import { accountHoldings } from '../data/positions.js'; @@ -156,8 +156,9 @@ function mountActivity(host, events, accountIds, { onPick = null, nowText = null return nowText && x === todayX ? `${day} · ${nowText}` : day; }; const marks = items.filter(it => it.dir === 0) - .map(it => ({ x: it.x, variant: MARK_VARIANT[it.kind] || 'account', label: label(it.x) })); - if (nowText) marks.push({ x: todayX, variant: 'now', label: label(todayX) }); + .map(it => ({ x: it.x, variant: MARK_VARIANT[it.kind] || 'account', label: label(it.x) })) + .sort((a, b) => (a.variant === 'balance') - (b.variant === 'balance')); + if (nowText) marks.unshift({ x: todayX, variant: 'now', label: label(todayX) }); const peak = Math.max(1, ...beat.points.map(p => Math.abs(p[1]))); mountSparkline(host, beat.points, { yRange: [-peak, peak], diff --git a/client/pages/license.js b/client/pages/license.js index e338556..cae997f 100644 --- a/client/pages/license.js +++ b/client/pages/license.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:5dea810da6d84ed187a1154955f4194498f812771e3ddaa6b6dc7c547a305b8d +// Generated, do not edit. sha256:867f87b26d0b27fe51f4a0cb77d5196bad8cd8b58a6856168c9cad25f5776d99 import { t, localeTag } from '../i18n/index.js'; import { CONFIG } from '../../shared/config.js'; import { esc } from '../ui/escape.js'; @@ -8,7 +8,8 @@ import { refreshAttention } from '../ui/attention.js'; import { npubFromHex, shortKey, secretFromText, publicKeyOf, nsecFromSecret, newSecret } from '../nostr/keys.js'; import { keySigner, extensionSigner, nip98Header } from '../nostr/nip98.js'; import { qrSvg, invoiceQrText } from '../ui/qr.js'; -import { CHECK, CHEVRON } from '../ui/icons.js'; +import { CHECK, CHEVRON, IMAGE } from '../ui/icons.js'; +import { setPageHint } from '../ui/page-hint.js'; import { splashMarkHtml } from '../ui/splash.js'; import { expanders } from '../ui/expand.js'; import { supportInfo, supportMessages, sendSupport, supportAttachment } from '../data/support.js'; @@ -21,24 +22,21 @@ function buyerOf(s) { return { text: shortKey(npub ?? s.buyer, 10), title: npub ?? s.buyer ?? '' }; } -function lines(s) { +function standHtml(s) { const out = []; - const line = (text, title = '') => out.push({ text, title }); - - if (s.why === 'develop' || s.why === 'forced-develop') line(t('license.cardDevelop')); - line(s.level === 'full' ? t('license.cardFull') : t('license.cardFree')); if (s.installed) { const buyer = buyerOf(s); - line(t('license.cardFacts', { - buyer: buyer.text, issued: s.issued ?? '', - from: s.installed.majorFrom, + const range = t('license.cardFacts', { + issued: s.issued ?? '', from: s.installed.majorFrom, to: s.installed.majorTo === 'unlimited' ? t('license.unlimited') : s.installed.majorTo, - }), buyer.title); - if (!s.installedCovers) line(t('license.cardOutOfRange', { version: s.version })); + }); + const [before, after] = t('license.cardFor', { npub: '§' }).split('§'); + out.push(`

${esc(before)}${esc(buyer.text)}${esc(after)}

`); + } else { + out.push(`

${esc(t(s.level === 'full' ? 'license.cardFull' : 'license.cardFree'))}

`); } - if (BROKEN.has(s.why)) line(`${t('license.cardProblem')} ${t(`license.why_${s.why}`)}.`); - if (s.level !== 'full') line(t('license.cardBuy')); - return out; + if (BROKEN.has(s.why)) out.push(`

${esc(`${t('license.cardProblem')} ${t(`license.why_${s.why}`)}.`)}

`); + return out.join(''); } async function installAndReload(text, message) { @@ -57,17 +55,16 @@ async function installAndReload(text, message) { const INFO = ['Nostr', 'Why', 'SignIn', 'Zap', 'Privacy']; const link = (url, html) => `${html}`; -const payHtml = (expand) => `
${say('license.payTitle')}
-

${say('license.payIntro')}

` - + ['easy', 'other'].map(group => `
${say(`license.payGroup_${group}`)}
` - + CONFIG.LICENSE.PAY_APPS.filter(a => a.group === group) - .map(a => `

${link(a.url, `${esc(a.name)}`)} ${say(`license.payApp_${a.id}`)}

`).join('') - + '
').join('') - + `

${say('license.payNote')}

-
${say('license.nostrMore')}` - + INFO.map(k => `

${say(`license.info${k}Head`)} ${say(`license.info${k}`)}

`).join('') - + CONFIG.LICENSE.INFO_LINKS.map(l => `

${link(l.url, say(`license.link_${l.id}`))}

`).join('') - + '
'; +const legendRows = () => [ + say('license.payIntro'), + ...['easy', 'other'].flatMap(group => [{ heading: say(`license.payGroup_${group}`) }, + ...CONFIG.LICENSE.PAY_APPS.filter(a => a.group === group) + .map(a => `${link(a.url, `${esc(a.name)}`)} ${say(`license.payApp_${a.id}`)}`)]), + say('license.payNote'), + { heading: say('license.nostrMore') }, + ...INFO.map(k => `${say(`license.info${k}Head`)} ${say(`license.info${k}`)}`), + ...CONFIG.LICENSE.INFO_LINKS.map(l => link(l.url, say(`license.link_${l.id}`))), +]; let signer = null; let newKey = null; @@ -91,12 +88,12 @@ async function drawSignIn(box, s) { const who = t(signer.kind === 'extension' ? 'license.signedInExtension' : 'license.signedIn', { npub: '§' }); const [before, after] = who.split('§'); const other = s.installed && s.buyer && s.buyer !== signer.pubkey; - box.innerHTML = `${head} -

${esc(before)}${npubText(signer.pubkey)}${esc(after)}

+ box.innerHTML = ` +
${esc(before)}${npubText(signer.pubkey)}${esc(after)} +
${other ? `

${say('license.otherBuyer')}

` : ''}
-

-
`; +

`; box.querySelector('[data-signout]').onclick = () => { signer = null; drawSignIn(box, s); }; await drawLicenses(box.querySelector('[data-licenses]'), box.querySelector('[data-signin-msg]'), shop); return; @@ -147,7 +144,7 @@ async function drawSignIn(box, s) {
- ${hasExtension ? '' : `

${say('license.signInExtensionNone')}

`} + ${hasExtension ? '' : `

${say('license.signInExtensionNone')}

`}
`; } -function placeShot(shot, row) { +function placeShot(shot, anchor) { const gap = 8, pad = 8; - const r = row.getBoundingClientRect(); + const r = anchor.getBoundingClientRect(); const w = shot.offsetWidth, h = shot.offsetHeight; let top = r.top - gap - h; if (top < pad) top = r.bottom + gap; - const left = Math.min(Math.max(pad, r.left + 24), window.innerWidth - pad - w); + const left = Math.min(Math.max(pad, r.left + r.width / 2 - w / 2), window.innerWidth - pad - w); shot.style.left = `${left}px`; shot.style.top = `${Math.min(Math.max(pad, top), window.innerHeight - pad - h)}px`; } @@ -531,12 +529,12 @@ function bindFeatures(root) { document.body.appendChild(shot); let current = null; let on = null; - const show = (row) => { - if (row === on && !shot.hidden) return; - on = row; + const show = (row, anchor = row) => { + if (anchor === on && !shot.hidden) return; + on = anchor; root.querySelectorAll('[data-feature]').forEach(r => r.classList.toggle('is-on', r === row)); shot.hidden = false; - placeShot(shot, row); + placeShot(shot, anchor); const id = row.dataset.feature; if (id === current) return; current = id; @@ -555,8 +553,9 @@ function bindFeatures(root) { }; const over = (e) => { if (!root.isConnected) { stop(); return; } - const row = e.target.closest?.('[data-feature]'); - if (row && root.contains(row)) show(row); else hide(); + const mark = e.target.closest?.(MARKS); + const row = mark?.closest('[data-feature]'); + if (row && root.contains(row)) show(row, mark); else hide(); }; const stop = () => { shot.remove(); @@ -574,35 +573,27 @@ function bindFeatures(root) { export async function render(el) { const s = licenseSnapshot() ?? await loadLicense(); - const expand = await expanders('license', { - nostr: false, ...Object.fromEntries(CONFIG.LICENSE.FEATURE_GROUPS.map(g => [groupKey(g), false])), - }); + const expand = await expanders('license', Object.fromEntries(CONFIG.LICENSE.FEATURE_GROUPS.map(g => [groupKey(g), false]))); el.innerHTML = `
+
+
${featuresHtml(expand)}
+
${esc(t('license.cardTitle'))}
- ${esc(t('license.cardVersion', { version: s.version }))} + ${esc(t('license.cardVersion', { version: s.version }))}
- ${lines(s).map(r => `

${esc(r.text)}

`).join('')} -
- ${esc(t('license.dropHere'))} - ${esc(t('license.dropOr'))} - -
- + ${standHtml(s)}
-
+
-
${payHtml(expand)}
-
-
-
${featuresHtml(expand)}
`; + setPageHint(el, { title: t('license.payTitle'), rows: legendRows() }); expand.bind(el); bindFeatures(el.querySelector('[data-features]')); buyBox = el.querySelector('[data-buy]'); @@ -610,33 +601,4 @@ export async function render(el) { drawSignIn(el.querySelector('[data-signin]'), s); markLicenseSeen().then(() => refreshAttention()).catch(() => { }); - - const message = el.querySelector('#lic-msg'); - const install = (text) => installAndReload(text, message); - - const MAX = 64 * 1024; - const zone = el.querySelector('#lic-drop'); - const picker = el.querySelector('#lic-file'); - - async function fromFile(file) { - if (!file) return; - if (file.size > MAX) { - message.className = 't-body-sm t-neg'; - message.textContent = t('license.dropTooBig'); - return; - } - await install(await file.text()); - } - - zone.onclick = () => picker.click(); - zone.onkeydown = (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); picker.click(); } }; - picker.onchange = () => fromFile(picker.files?.[0]); - - zone.ondragover = (e) => { e.preventDefault(); zone.classList.add('is-over'); }; - zone.ondragleave = () => zone.classList.remove('is-over'); - zone.ondrop = (e) => { - e.preventDefault(); - zone.classList.remove('is-over'); - fromFile(e.dataTransfer?.files?.[0]); - }; } diff --git a/client/pages/portfolios.js b/client/pages/portfolios.js new file mode 100644 index 0000000..ce2b6f1 --- /dev/null +++ b/client/pages/portfolios.js @@ -0,0 +1,420 @@ +// Generated, do not edit. sha256:86d4e38921922eb14e5463ba3c4d6855cd2e5276d5295930d9126848cf48e05c +import { t, localeTag } from '../i18n/index.js'; +import { serverFoutTekst } from '../data/_rpc.js'; +import { esc } from '../ui/escape.js'; +import * as dialog from '../ui/dialog.js'; +import { setPageHint } from '../ui/page-hint.js'; +import { getSettings, updateSettings } from '../data/preferences.js'; +import { firstPositionDate } from '../data/positions.js'; +import { switchPortfolio, reloadWhenBack, refreshActivePortfolio } from '../portfolio.js'; +import { backupDb, exportDb, restoreDb, startFresh } from './db-file.js'; +import { openPopover, closePopover } from '../ui/popover.js'; +import { expanders } from '../ui/expand.js'; +import { PLUS, CHEVRON } from '../ui/icons.js'; +import { currencyName } from '../ui/format.js'; +import { CONFIG, ENUMS } from '../../shared/config.js'; +import { counterText, limitFor, locked } from '../license.js'; +import { counterHtml } from '../ui/lock.js'; +import { baseCurrency } from '../app-settings.js'; +import { openSetup } from '../onboarding/setup.js'; + +async function api(pad, body) { + const opties = body + ? { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } + : {}; + const r = await fetch(pad, opties); + if (r.status === 401) { + location.replace(CONFIG.AUTH.LOGIN_PATH); + throw new Error(t('common.sessionExpired')); + } + const uit = await r.json().catch(() => null); + if (!r.ok) throw new Error(serverFoutTekst(uit) || `HTTP ${r.status}`); + return uit; +} + +const datum = (iso) => (iso ? new Date(iso).toLocaleDateString(localeTag()) : null); + +const DAG_MS = 24 * 60 * 60 * 1000; + +const backupTeOud = (iso) => !iso || Date.now() - new Date(iso).getTime() > CONFIG.BACKUP.REMIND_AFTER_DAYS * DAG_MS; + +function menuItems(p, { full, beheer }) { + if (!beheer) return []; + const kopie = p.heeftDatabase && !full ? [['kopieer', t('portfolios.copy')]] : []; + return p.actief + ? [...kopie, ['exporteer', t('dbfile.export')], ['terugzetten', t('dbfile.import')], ['inrichten', t('setup.rerun')], + ['leeg', t('dbfile.fresh')]] + : [...kopie, ['hernoem', t('portfolios.rename')], ['verwijder', t('portfolios.remove')]]; +} + +function feitHtml(label, waarde, { late = false } = {}) { + return `
${label}
${waarde}
`; +} + +const soortenVan = (telling, enumNaam) => ENUMS[enumNaam.toUpperCase()].filter(k => telling?.[k]); + +function perSoortHtml(label, telling, enumNaam, regels) { + const getal = (n) => esc(Number(n).toLocaleString(localeTag())); + const soorten = soortenVan(telling, enumNaam); + const totaal = soorten.reduce((s, k) => s + telling[k], 0); + const lijst = soorten.map(k => `
  • ${esc(t(`enums.${enumNaam}.${k}`))}${getal(telling[k])}
  • `).join(''); + return `
    ${label}
    ${getal(totaal)}
    +
      ${lijst}
    `; +} + +function kaartHtml(p, { full, beheer, regels }) { + const k = p.kerncijfers; + const getal = (n) => esc(Number(n).toLocaleString(localeTag())); + const sub = !p.heeftDatabase ? t('portfolios.noDatabase') + : k && k.munt ? esc(k.eersteJaar ? t('portfolios.cardSince', { munt: k.munt, jaar: k.eersteJaar }) : k.munt) + : ''; + const feiten = !k ? '' : `
    + ${perSoortHtml(t('portfolios.factAssets'), k.assets, 'asset_kind', regels)} + ${perSoortHtml(t('portfolios.factAccounts'), k.accounts, 'account_kind', regels)} + ${feitHtml(t('portfolios.factEvents'), getal(k.boekingen))} + ${feitHtml(t('portfolios.factValuations'), getal(k.balansen))} + ${feitHtml(t('portfolios.factLastUsed'), esc(datum(p.laatstGebruikt) || t('portfolios.never')))} + ${beheer ? feitHtml(t('portfolios.factBackup'), esc(datum(k.laatsteBackup) || t('portfolios.backupNever')), + { late: backupTeOud(k.laatsteBackup) }) : '
    '} +
    `; + const backupKlasse = k && backupTeOud(k.laatsteBackup) ? 'btn-primary' : 'btn-secondary'; + const hoofd = !p.actief + ? `` + : ` + ${beheer ? `` : ''}`; + const menu = menuItems(p, { full, beheer }).length + ? `` + : ''; + return `
    +
    +
    ${esc(p.naam)}
    + ${p.demo ? `${t('portfolios.demoBadge')}` : ''} + ${p.actief ? `${t('portfolios.openNow')}` : ''} +
    +
    ${sub}
    + ${feiten} +
    ${hoofd}${menu}
    +
    `; +} + +function archiefRijHtml(a) { + return `
    +
    +
    ${esc(a.naam)}
    +
    ${esc(datum(a.gearchiveerd) || '')}
    +
    + +
    `; +} + +function authHtml(auth) { + const stand = auth.bron === 'omgeving' ? t('portfolios.authEnv') + : auth.ingesteld ? t('portfolios.authSet') + : t('portfolios.authNone'); + const knoppen = auth.wijzigbaar + ? ` + ${auth.ingesteld ? `` : ''}` + : ''; + const uitloggen = auth.ingesteld + ? `` + : ''; + return `
    +
    ${t('portfolios.authTitle')}
    +
    ${stand}
    +
    ${knoppen}${uitloggen}
    +
    `; +} + +function startJaarHtml({ gekozen, eersteJaar, huidigJaar }) { + const AUTO = CONFIG.START_YEAR.AUTO; + let inhoud; + if (eersteJaar == null) { + inhoud = `
    ${t('portfolios.startYearEmpty')}
    `; + } else { + const eersteKolom = Math.min(Math.max(eersteJaar + 1, gekozen), huidigJaar); + const stand = gekozen === AUTO + ? t('portfolios.startYearAutoState', { jaar: eersteKolom }) + : t('portfolios.startYearState', { jaar: eersteKolom, eerste: eersteJaar }); + const jaren = []; + for (let y = eersteJaar; y <= huidigJaar; y++) jaren.push(y); + if (gekozen !== AUTO && !jaren.includes(gekozen)) jaren.unshift(gekozen); + const opties = [``] + .concat(jaren.map(y => ``)); + inhoud = `
    ${stand}
    +
    + + +
    `; + } + return `
    +
    ${t('portfolios.startYearTitle')}
    + ${inhoud} +
    `; +} + +function rendementHtml({ gekozen }) { + const opties = ENUMS.MWR_METHOD + .map(m => ``) + .join(''); + return `
    +
    ${t('portfolios.mwrTitle')}
    +
    + + +
    +
    `; +} + +async function instellingenHtml() { + const [auth, instellingen, eerstePositie] = await Promise.all([ + api('/api/auth/status'), getSettings(), firstPositionDate(), + ]); + return authHtml(auth) + startJaarHtml({ + gekozen: Number(instellingen.start_year) || CONFIG.START_YEAR.AUTO, + eersteJaar: eerstePositie ? Number(eerstePositie.slice(0, 4)) : null, + huidigJaar: new Date().getFullYear(), + }) + rendementHtml({ gekozen: String(instellingen.mwr_method || 'dietz') }); +} + +async function openInstellingen(naam) { + const html = await instellingenHtml(); + const klaar = dialog.detail({ title: t('portfolios.settingsOf', { naam }), html: `
    ${html}
    ` }); + const host = document.querySelector('[data-pf-settings]'); + host?.closest('.dialog')?.classList.add('pf-settings-dialog'); + const ververs = async () => { if (host?.isConnected) host.innerHTML = await instellingenHtml(); }; + const fout = (e) => dialog.alert({ title: t('dialog.error'), message: e.message }); + if (host) { + host.onclick = async (ev) => { + const knop = ev.target.closest('[data-actie]'); + if (!knop) return; + try { + if (knop.dataset.actie === 'auth-zet' && await authZetten()) await ververs(); + if (knop.dataset.actie === 'auth-leeg' && await authLeegmaken()) await ververs(); + if (knop.dataset.actie === 'auth-uit') await uitloggen(); + } catch (e) { fout(e); } + }; + host.onchange = async (ev) => { + const veld = ev.target.matches('#mwrmethode') ? { mwr_method: ev.target.value } + : ev.target.matches('#startjaar') ? { start_year: Number(ev.target.value) } : null; + if (!veld) return; + try { + await updateSettings(veld); + document.dispatchEvent(new Event('settings-changed')); + await ververs(); + } catch (e) { fout(e); } + }; + } + await klaar; +} + +export async function render(el) { + const [overzicht, expand] = await Promise.all([ + api('/api/portfolios'), expanders('portfolios', { archive: false }), + ]); + refreshActivePortfolio(); + const beheer = !locked('portfolios'); + const max = limitFor('portfolios'); + const eigen = overzicht.portefeuilles.filter(p => !p.demo).length; + const full = max !== null && eigen >= max; + + const aangemaakt = p => p.kerncijfers?.aangemaakt || ''; + const lijst = [...overzicht.portefeuilles] + .sort((a, b) => aangemaakt(a).localeCompare(aangemaakt(b)) || a.naam.localeCompare(b.naam, localeTag())); + const regels = Math.max(1, ...lijst.map(p => Math.max( + soortenVan(p.kerncijfers?.assets, 'asset_kind').length, soortenVan(p.kerncijfers?.accounts, 'account_kind').length))); + const nieuwTegel = full + ? `
    ${counterHtml(counterText('portfolios', eigen))}
    ` + : `
    `; + + const archief = beheer && overzicht.archief.length + ? `
    + ${CHEVRON}${t('portfolios.archiveTitle')} + ${overzicht.archief.length} +
    ${overzicht.archief.map(archiefRijHtml).join('')}
    +
    ` + : ''; + + el.innerHTML = ` +
    + ${lijst.map(p => kaartHtml(p, { full, beheer, regels })).join('')} + ${nieuwTegel} +
    + ${archief ? `
    ${archief}
    ` : ''}`; + expand.bind(el); + + const instellingenUitleg = [ + { heading: t('portfolios.authTitle') }, t('portfolios.authHint'), + { heading: t('portfolios.startYearTitle') }, t('portfolios.startYearHint'), + { heading: t('portfolios.mwrTitle') }, + t('portfolios.mwrHint'), t('portfolios.mwrState_dietz'), t('portfolios.mwrState_irr'), + ]; + setPageHint(el, { + title: t('portfolios.hintTitle'), + rows: beheer ? [ + { heading: t('portfolios.title') }, + t('portfolios.intro'), t('portfolios.createHint'), t('portfolios.createCurrencyHint'), + { heading: t('portfolios.backupTitle') }, t('dbfile.hint'), t('portfolios.backupLateHint', { dagen: CONFIG.BACKUP.REMIND_AFTER_DAYS }), + ...instellingenUitleg, + { heading: t('portfolios.archiveTitle') }, t('portfolios.archiveIntro'), + ] : [ + { heading: t('portfolios.title') }, t('portfolios.intro'), t('portfolios.demoHint'), + ...instellingenUitleg, + ], + }); + + const opnieuw = () => render(el); + const fout = (e) => dialog.alert({ title: t('dialog.error'), message: e.message }); + + async function doe(actie, naam) { + try { + switch (actie) { + case 'open': await open(naam); break; + case 'nieuw': if (await nieuw()) await opnieuw(); break; + case 'kopieer': if (await kopieer(naam)) await opnieuw(); break; + case 'instellingen': await openInstellingen(naam); break; + case 'backup': if (await backupDb()) await opnieuw(); break; + case 'exporteer': await exportDb(); await opnieuw(); break; + case 'terugzetten': restoreDb(opnieuw); break; + case 'leeg': await startFresh(opnieuw); break; + case 'inrichten': await openSetup({ rerun: true }); await opnieuw(); break; + case 'hernoem': if (await hernoem(naam)) await opnieuw(); break; + case 'verwijder': if (await verwijder(naam)) await opnieuw(); break; + case 'wis': if (await wis(naam)) await opnieuw(); break; + } + } catch (e) { fout(e); } + } + + function openMenu(knop) { + const p = lijst.find(x => x.naam === knop.dataset.menu); + if (!p) return; + const { el: pop, position } = openPopover(knop, { className: 'popover new-menu' }); + pop.innerHTML = menuItems(p, { full, beheer }).map(([actie, label]) => + ``).join(''); + position(); + pop.onclick = (ev) => { + const item = ev.target.closest('[data-actie]'); + if (!item) return; + closePopover(); + doe(item.dataset.actie, p.naam); + }; + } + + el.onclick = (ev) => { + const menuKnop = ev.target.closest('[data-menu]'); + if (menuKnop) { openMenu(menuKnop); return; } + const knop = ev.target.closest('[data-actie]'); + if (knop) doe(knop.dataset.actie, knop.dataset.naam); + }; +} + +async function open(naam) { + if (!await dialog.confirm({ message: t('portfolios.activateConfirm', { naam }) })) return; + const uit = await switchPortfolio(naam); + if (!uit.supervised) { + await dialog.alert({ message: t('portfolios.activateNoSupervisor', { naam }) }); + return; + } + dialog.notice({ message: t('portfolios.activateWaiting') }); + await reloadWhenBack(); +} + +async function nieuw() { + const res = await dialog.form({ + title: t('portfolios.create'), + fields: [ + { key: 'naam', label: t('portfolios.createName'), placeholder: t('portfolios.createNameHint') }, + { + key: 'munt', label: t('portfolios.createCurrency'), type: 'select', + options: CONFIG.PORTFOLIO.BASE_CURRENCIES.map(code => ({ value: code, label: `${currencyName(code)} (${code})` })), + value: baseCurrency(), + }, + ], + confirmLabel: t('portfolios.createConfirm'), + }); + if (!res) return false; + const uit = await api('/api/portfolios/create', { naam: res.naam, kopieVan: null, baseCurrency: res.munt }); + await dialog.alert({ message: t('portfolios.createDone', { naam: uit.naam }) }); + return true; +} + +async function kopieer(bron) { + const res = await dialog.form({ + title: t('portfolios.copyTitle', { naam: bron }), + fields: [{ key: 'naam', label: t('portfolios.copyName'), placeholder: t('portfolios.createNameHint') }], + confirmLabel: t('portfolios.copyConfirm'), + }); + if (!res) return false; + const uit = await api('/api/portfolios/create', { naam: res.naam, kopieVan: bron, baseCurrency: null }); + await dialog.alert({ message: t('portfolios.copyDone', { naam: uit.naam, bron }) }); + return true; +} + +async function hernoem(naam) { + const res = await dialog.form({ + title: t('portfolios.rename'), + fields: [{ key: 'naar', label: t('portfolios.renameTo'), value: naam }], + confirmLabel: t('portfolios.rename'), + }); + if (!res) return false; + const uit = await api('/api/portfolios/rename', { van: naam, naar: res.naar }); + await dialog.alert({ message: t('portfolios.renameDone', { naam: uit.naar }) }); + return true; +} + +async function verwijder(naam) { + const res = await dialog.form({ + title: t('portfolios.remove'), + fields: [{ key: 'bevestiging', label: t('portfolios.removeConfirm', { naam }) }], + confirmLabel: t('portfolios.remove'), + }); + if (!res) return false; + if (res.bevestiging.trim() !== naam) { + await dialog.alert({ title: t('dialog.error'), message: t('portfolios.removeMismatch') }); + return false; + } + await api('/api/portfolios/archive', { naam }); + await dialog.alert({ message: t('portfolios.removeDone', { naam }) }); + return true; +} + +async function wis(naam) { + const res = await dialog.form({ + title: t('portfolios.purge'), + fields: [{ key: 'bevestiging', label: t('portfolios.purgeConfirm', { naam }) }], + confirmLabel: t('portfolios.purge'), + }); + if (!res) return false; + if (res.bevestiging.trim() !== naam) { + await dialog.alert({ title: t('dialog.error'), message: t('portfolios.removeMismatch') }); + return false; + } + await api('/api/portfolios/purge', { naam }); + await dialog.alert({ message: t('portfolios.purgeDone', { naam }) }); + return true; +} + +async function authZetten() { + const res = await dialog.form({ + title: t('portfolios.authChange'), + fields: [{ key: 'password', label: t('portfolios.authPassword'), type: 'password' }], + confirmLabel: t('portfolios.authSave'), + }); + if (!res) return false; + await api('/api/auth/set', { password: res.password }); + await dialog.alert({ message: t('portfolios.authDone') }); + return true; +} + +async function uitloggen() { + if (!await dialog.confirm({ message: t('portfolios.authLogoutConfirm') })) return; + await api('/api/logout', {}); + location.replace(CONFIG.AUTH.LOGIN_PATH); +} + +async function authLeegmaken() { + if (!await dialog.confirm({ message: t('portfolios.authClearConfirm'), danger: true })) return false; + await api('/api/auth/clear', {}); + await dialog.alert({ message: t('portfolios.authClearedDone') }); + return true; +} diff --git a/client/pages/price-history.js b/client/pages/price-history.js deleted file mode 100644 index a40efd9..0000000 --- a/client/pages/price-history.js +++ /dev/null @@ -1,790 +0,0 @@ -// Generated, do not edit. sha256:242a49647c9f6c4f00caf9c66c75b5120a0a8d45f2c0c051b6878a5f798ae976 -import { tableViewCfg } from '../data/preferences.js'; -import { - addManualPricePoint, upsertPriceHistory, listAllPriceHistory, listPriceGaps, listPriceHistory, - ignorePriceGap, listIgnoredPriceGaps, unignorePriceGap, listPriceAbsences, deletePriceAbsences, -} from '../data/price-history.js'; -import { listAssets } from '../data/assets.js'; -import { deleteTableRow } from '../data/table-viewer.js'; -import { t, localeTag } from '../i18n/index.js'; -import { fmtBasePrice, priceFromBase, isBaseAsset } from '../ui/format.js'; -import { dayNl } from '../../shared/time.js'; -import { baseCurrency, appSetting } from '../app-settings.js'; -import { serviceCoverage } from '../data/market.js'; -import { renderTable } from '../ui/table.js'; -import { mountSparkline } from '../ui/sparkline.js'; -import { fetchPriceVia, primaryProvider, fillClosesFor, daysToAsk } from '../price/providers.js'; -import { getProvider, listProviders } from '../data/providers.js'; -import { apiMetricsTotals } from '../data/api-metrics.js'; -import { priceSourceChain } from '../data/price-source.js'; -import { loadMatrixContext, matrixCardHtml, wireMatrix } from '../ui/source-matrix.js'; -import { diagnoseSources } from '../../shared/source-diagnosis.js'; -import { attentionDotHtml } from '../ui/attention.js'; -import { hygieneReport } from '../data/hygiene.js'; -import { dailyProvenance, provenanceCounts, provenanceRuns, PROVENANCE_KINDS } from '../../shared/price-provenance.js'; -import { esc } from '../ui/escape.js'; -import { assetLabel, assetLabelHtml, byKindAndLabel } from '../ui/asset-label.js'; -import { REFRESH, EYE_OFF, EYE, CHEVRON_RIGHT, CLOSE } from '../ui/icons.js'; -import { create as createTabs } from '../ui/tabs.js'; -import { expanders } from '../ui/expand.js'; -import { notesHtml, mountNotes } from '../ui/notes.js'; -import * as dialog from '../ui/dialog.js'; -import { ENUMS, CONFIG } from '../../shared/config.js'; -import { loadCharting, readPalette } from '../ui/chart-setup.js'; -import { hexToRgb } from '../ui/charting.js'; -import { isMetal, priceUnitLabel } from '../../shared/units.js'; - -const todayIso = () => new Date().toISOString().slice(0, 10); - -export const title = () => t('priceHistory.title'); - -let phTable = null; - -function localDateParts(iso) { - const d = new Date(iso); - const p = n => String(n).padStart(2, '0'); - return { date: `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`, time: `${p(d.getHours())}:${p(d.getMinutes())}` }; -} -function fmtDateTime(ts) { - return new Intl.DateTimeFormat(localeTag(), { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }).format(new Date(ts * 1000)); -} -function displayDate(r) { return r.resolution === 'timestamp' ? localDateParts(r.observedAt).date : r.observedAt.slice(0, 10); } -function resLabel(res) { return res === 'timestamp' ? t('priceHistory.resTimestamp') : t('priceHistory.resDay'); } -const dash = '-'; - -async function fetchDayPoint(sourceKey, asset, dateKey) { - const midnight = Math.floor(Date.parse(`${dateKey}T00:00:00Z`) / 1000); - let pt = null; - try { pt = await fetchPriceVia(sourceKey, asset, 'history_point', dateKey); } catch { pt = null; } - if (!pt) { - try { - const grid = await fetchPriceVia(sourceKey, asset, 'daily_history', dateKey); - if (Array.isArray(grid)) pt = grid.find(x => new Date(x.time * 1000).toISOString().slice(0, 10) === dateKey) || null; - } catch { } - } - if (!pt && dateKey === todayIso()) { - try { const s = await fetchPriceVia(sourceKey, asset, 'spot', dateKey); if (s && Number.isFinite(s.price)) pt = { time: midnight, price: s.price }; } catch { } - } - if (!pt || !Number.isFinite(pt.price)) return null; - return { time: pt.time ?? midnight, price: pt.price }; -} -async function fetchSpotPoint(sourceKey, asset) { - let s = null; - try { s = await fetchPriceVia(sourceKey, asset, 'spot', null); } catch { return null; } - if (!s || !Number.isFinite(s.price)) return null; - return { time: Math.floor(Date.now() / 1000), price: s.price }; -} - -export async function render(el) { - el.innerHTML = `
    `; - alleAssets = await listAssets(); - await renderCards(el); -} - -const CARD_DAYS = 365; -let kaarten = new Map(); -let manualId = null; -let bronNamen = new Map(); - -async function renderCards(el) { - const host = el.querySelector('#ph-gaps'); - if (!host) return; - let gaten, genegeerd, manual, bronnen, controle, afwezig; - try { - [gaten, genegeerd, manual, bronnen, controle, afwezig] = await Promise.all([listPriceGaps(), listIgnoredPriceGaps(), - getProvider('manual').catch(() => null), bronContext().catch(() => null), - hygieneReport({ kinds: CONTROLE_SOORTEN }).catch(() => null), listPriceAbsences().catch(() => [])]); - } catch { host.innerHTML = ''; return; } - const verdachtPerAsset = new Map(); - for (const f of (controle && controle.findings) || []) { - for (const r of f.rows) { - const aid = r.row.assetId; - if (!verdachtPerAsset.has(aid)) verdachtPerAsset.set(aid, new Map()); - const perSoort = verdachtPerAsset.get(aid); - if (!perSoort.has(f.kind)) perSoort.set(f.kind, []); - perSoort.get(f.kind).push(r); - } - } - manualId = manual ? manual.id : null; - if (bronnen) bronNamen = new Map(bronnen.providers.map(p => [p.id, p.name])); - const groepeer = rijen => { - const m = new Map(); - for (const g of rijen) { if (!m.has(g.assetId)) m.set(g.assetId, []); m.get(g.assetId).push(g); } - return m; - }; - const perAsset = groepeer(gaten.rows); - const genegeerdPerAsset = groepeer(genegeerd); - const afwezigPerAsset = groepeer(afwezig); - const vandaag = todayIso(); - const venster = shiftIso(vandaag, -(CARD_DAYS - 1)); - const nieuw = new Map(); - for (const asset of [...alleAssets].sort(byKindAndLabel)) { - if (isBaseAsset(asset)) continue; - let rijen = []; - try { rijen = await listPriceHistory(asset.id); } catch { rijen = []; } - if (!rijen.length && !perAsset.has(asset.id) && !genegeerdPerAsset.has(asset.id)) continue; - const eerste = rijen.length ? rijen[rijen.length - 1].observedAt.slice(0, 10) : vandaag; - const dagen = dailyProvenance(rijen, { - assetKind: asset.kind, manualProviderId: manualId, today: vandaag, - from: eerste > venster ? eerste : venster, until: vandaag, - }); - let bevindingen = []; - if (bronnen) { - try { - const historyChain = await priceSourceChain(asset.id, 'history'); - bevindingen = diagnoseSources(asset, { providers: bronnen.providers, historyChain, usage: bronnen.usage, - serviceCovers: bronnen.serviceCovered.has(asset.id) }); - } catch { bevindingen = []; } - } - const verdacht = [...(verdachtPerAsset.get(asset.id) || new Map())].map(([kind, rows]) => ({ kind, rows })); - nieuw.set(asset.id, { - asset, dagen, gaps: perAsset.get(asset.id) || [], ignored: genegeerdPerAsset.get(asset.id) || [], - absent: afwezigPerAsset.get(asset.id) || [], bevindingen, verdacht, - }); - } - kaarten = nieuw; - const meer = gaten.total > gaten.rows.length - ? `
    ${esc(t('priceHistory.gapsMore', { n: gaten.total - gaten.rows.length }))}
    ` : ''; - const html = [...kaarten.values()].map(kaartHtml).join(''); - host.innerHTML = `${html ? `
    ${html}
    ` : ''}${meer}`; - for (const k of kaarten.values()) tekenLijn(host, k); - const grid = host.querySelector('.ph-grid'); - grid?.addEventListener('click', e => { - const kaart = e.target.closest('[data-detail]'); - if (kaart) openDetail(el, Number(kaart.dataset.detail)); - }); - grid?.addEventListener('keydown', e => { - if (e.key !== 'Enter' && e.key !== ' ') return; - const kaart = e.target.closest('[data-detail]'); - if (kaart && e.target === kaart) { e.preventDefault(); openDetail(el, Number(kaart.dataset.detail)); } - }); -} - -async function bronContext() { - const month = new Date().toISOString().slice(0, 7); - const providers = (await Promise.all((await listProviders()).map(p => getProvider(p.key)))).filter(Boolean); - const usage = {}; - for (const p of providers) { - if (!p.callsPerMonth) continue; - try { usage[p.id] = (await apiMetricsTotals(p.id, `${month}-01T00:00`)).calls; } catch { } - } - return { providers, usage, serviceCovered: await serviceCovered() }; -} - -async function serviceCovered() { - let mode = 'off'; - try { mode = appSetting('market_spot'); } catch { } - if (mode === 'off') return new Set(); - try { - const r = await serviceCoverage(); - return new Set(r.status === 'ok' ? r.assetIds : []); - } catch { return new Set(); } -} - -const CONTROLE_SOORTEN = ['price_unit_swap', 'price_outlier', 'price_sources_disagree', - 'price_not_positive', 'price_in_future']; - -function meldingenVan({ gaps, bevindingen = [], verdacht = [] }) { - const uit = bevindingen.map(b => ({ severity: b.severity, tekst: t(`priceHistory.diagCard_${b.code}`, { namen: (b.names || []).join(', ') }) })); - const n = verdacht.reduce((s, v) => s + v.rows.length, 0); - if (n) uit.push({ severity: 'attention', tekst: telTekst('suspect', n) }); - const dagen = gaps.reduce((s, g) => s + g.days, 0); - if (gaps.length) uit.push({ severity: 'attention', tekst: t('priceHistory.cardGaps', { gaten: telTekst('gapCount', gaps.length), dagen: telTekst('dayCount', dagen) }) }); - return uit; -} -const meldingHtml = m => `${attentionDotHtml([{ severity: m.severity, label: m.tekst, fade: 'full' }])}${esc(m.tekst)}`; - -const daysIncl = (from, until) => Math.round((Date.parse(`${until}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`)) / 86400000) + 1; -const shiftIso = (day, n) => new Date(Date.parse(`${day}T00:00:00Z`) + n * 86400000).toISOString().slice(0, 10); -const kindLabel = kind => t(`priceHistory.kind_${kind}`); -const telTekst = (stam, n) => t(`priceHistory.${stam}${n === 1 ? 'One' : 'Many'}`, { n }); -const soortTelling = (kind, n) => t('priceHistory.kindCount', { n, soort: t(`priceHistory.kindCount_${kind}${n === 1 ? 'One' : 'Many'}`) }); - -function kaartHtml(k) { - const { asset, dagen } = k; - const counts = provenanceCounts(dagen); - const telling = dagen.length - ? PROVENANCE_KINDS.filter(k => counts[k] > 0) - .map(k => `${esc(soortTelling(k, counts[k]))}`) - .join('') - : `${esc(t('priceHistory.cardNoPrices'))}`; - const periode = dagen.length ? `${esc(t('priceHistory.cardPeriod', { dagen: telTekst('dayCount', dagen.length) }))}` : ''; - const melding = meldingenVan(k).map(meldingHtml).join(''); - return `
    -
    - ${assetLabelHtml(asset)} - ${esc(t('enums.asset_kind.' + asset.kind))} -
    -
    ${periode}${telling}
    -
    ${melding}
    -
    -
    -
    -
    -
    `; -} - -function tekenLijn(host, { asset, dagen }) { - const lijnEl = host.querySelector(`[data-ph-spark="${asset.id}"]`); - const strookEl = host.querySelector(`[data-ph-strip="${asset.id}"]`); - if (!lijnEl || !strookEl || !dagen.length) return; - const perMs = new Map(); - const punten = []; - for (const d of dagen) { - if (d.fiatPrice == null) continue; - const ms = Date.parse(`${d.day}T00:00:00Z`); - perMs.set(ms, d); - punten.push([ms, priceFromBase(d.fiatPrice, asset)]); - } - mountSparkline(lijnEl, punten, { - tone: 'accent', - formatValue: (v, ms) => { - const d = perMs.get(ms); - return [fmtBasePrice(v),d ? d.day : null, d ? kindLabel(d.kind) : null].filter(Boolean).join(' · '); - }, - }); - tekenStrook(strookEl, dagen); -} - -function tekenStrook(strookEl, dagen) { - const n = dagen.length; - if (!n) { strookEl.innerHTML = ''; return; } - let x = 0; - const rects = provenanceRuns(dagen).map(r => { - const titel = r.days === 1 - ? t('priceHistory.stripDay', { dag: r.from, soort: kindLabel(r.kind) }) - : t('priceHistory.stripRange', { van: r.from, tot: r.until, soort: kindLabel(r.kind) }); - const rect = `${esc(titel)}`; - x += r.days; - return rect; - }).join(''); - strookEl.innerHTML = ``; -} - -let detailMelding = null; -let detail = null; -let detailChart = null; - -async function laadDetail(asset) { - let rijen = []; - try { rijen = await listPriceHistory(asset.id); } catch { rijen = []; } - detail = { assetId: asset.id, dagen: dailyProvenance(rijen, { assetKind: asset.kind, manualProviderId: manualId, today: todayIso() }) }; -} - -async function openDetail(el, assetId) { - const k = kaarten.get(assetId); - if (!k) return; - await laadDetail(k.asset); - dialog.detail({ title: assetLabel(k.asset), titleHtml: assetLabelHtml(k.asset), - asideHtml: `${t('enums.asset_kind.' + k.asset.kind)}`, - html: `
    -
    -
    -
    -
    -
    -
    ` }); - mountDetailTabs(el, assetId, 'provenance'); - tekenDetailGrafiek(k.asset).catch(() => {}); -} - -function mountDetailTabs(el, assetId, active) { - const host = document.querySelector('.dialog-overlay [data-detail-tabs]'); - const k = kaarten.get(assetId); - if (!host || !k) return; - createTabs(host, { - active, - items: [ - { id: 'provenance', label: t('priceHistory.tabProvenance') }, - { id: 'source', label: t('priceHistory.tabSource') }, - { id: 'check', label: t('priceHistory.tabCheck'), when: () => k.verdacht.length > 0 }, - { id: 'gaps', label: t('priceHistory.tabGaps'), when: () => k.gaps.length > 0 || k.ignored.length > 0 || k.absent.length > 0 }, - { id: 'prices', label: t('priceHistory.tabPrices') }, - { id: 'notes', label: t('notes.tab') }, - ], - render: (id, panel) => { - const m = detailMelding; - detailMelding = null; - const kop = m ? `
    ${esc(m)}
    ` : ''; - if (id !== 'prices') { koersFilter = null; koersFocus = null; } - if (id === 'source') bronPaneel(el, panel, k, kop).catch(e => { panel.innerHTML = kop + `
    ${esc(e.message)}
    `; }); - else if (id === 'check') { panel.innerHTML = kop + controleHtml(k); wireControle(el, panel, k); } - else if (id === 'gaps') gatenPaneel(el, panel, k, kop).catch(e => { panel.innerHTML = kop + `
    ${esc(e.message)}
    `; }); - else if (id === 'prices') koersenPaneel(el, panel, k, kop); - else if (id === 'notes') { panel.innerHTML = kop + notesHtml(); mountNotes(panel, k.asset.id); } - else { - panel.innerHTML = kop + herkomstHtml(k, detail && detail.assetId === assetId ? detail.dagen : k.dagen); - panel.querySelectorAll('[data-to-gap]').forEach(b => b.onclick = () => { - const [from, until] = b.dataset.toGap.split('|'); - gatFocus = { from, until }; - mountDetailTabs(el, assetId, 'gaps'); - }); - } - }, - }); -} - -async function naWijziging(el, assetId, tab, melding = null) { - document.dispatchEvent(new CustomEvent('price-gaps-changed')); - await renderCards(el); - detailMelding = melding; - const k = kaarten.get(assetId); - if (k) await laadDetail(k.asset); - mountDetailTabs(el, assetId, tab); - if (k) tekenDetailGrafiek(k.asset).catch(() => {}); -} - -async function tekenDetailGrafiek(asset) { - const canvas = document.querySelector('.dialog-overlay [data-ph-chart]'); - const strook = document.querySelector('.dialog-overlay [data-ph-detail-strip]'); - if (!canvas || !detail || detail.assetId !== asset.id) return; - if (strook) tekenStrook(strook, detail.dagen); - const Chart = await loadCharting(); - const pal = readPalette(); - const kleur = { close: pal.accent, manual: pal.blue, live: pal.accent, spot: pal.sigYellow, carried: pal.textSec, none: pal.sigRed }; - const punten = detail.dagen.map(d => ({ x: Date.parse(`${d.day}T00:00:00Z`), y: d.fiatPrice == null ? null : priceFromBase(d.fiatPrice, asset), d })); - const soortOp = i => punten[i] && punten[i].d.kind; - const rgb = hexToRgb(pal.accent) || { r: 128, g: 128, b: 128 }; - const schaduw = ({ chart }) => { - const a = chart.chartArea; - if (!a) return 'transparent'; - const g = chart.ctx.createLinearGradient(0, a.top, 0, a.top + a.height * 0.85); - g.addColorStop(0, `rgba(${rgb.r},${rgb.g},${rgb.b},0.28)`); - g.addColorStop(1, `rgba(${rgb.r},${rgb.g},${rgb.b},0)`); - return g; - }; - if (detailChart) detailChart.destroy(); - detailChart = new Chart(canvas.getContext('2d'), { - type: 'scatter', - data: { datasets: [{ - data: punten, showLine: true, spanGaps: false, borderWidth: 1.5, cubicInterpolationMode: 'monotone', - fill: 'start', backgroundColor: schaduw, - segment: { - borderColor: c => kleur[soortOp(c.p1DataIndex)] || pal.accent, - borderDash: c => (soortOp(c.p1DataIndex) === 'carried' ? [4, 3] : undefined), - }, - pointRadius: c => (['spot', 'manual'].includes(soortOp(c.dataIndex)) ? 2.5 : 0), - pointHoverRadius: 4, pointBorderWidth: 0, - pointBackgroundColor: c => kleur[soortOp(c.dataIndex)] || pal.accent, - }] }, - options: { - responsive: true, maintainAspectRatio: false, animation: false, - layout: { padding: { top: 6, bottom: 3 } }, - interaction: { mode: 'nearest', axis: 'x', intersect: false }, - plugins: { - legend: { display: false }, - tooltip: { - filter: i => i.parsed.y != null, - backgroundColor: pal.tooltipBg, borderColor: pal.border, borderWidth: 1, titleColor: pal.accent, bodyColor: pal.text, - callbacks: { - title: items => (items[0] ? punten[items[0].dataIndex].d.day : ''), - label: i => tooltipRegels(punten[i.dataIndex].d, i.parsed.y), - }, - }, - zoom: { zoom: { wheel: { enabled: true }, pinch: { enabled: true }, mode: 'x' }, pan: { enabled: true, mode: 'x' } }, - }, - scales: { - x: { type: 'linear', display: false }, - y: { display: false }, - }, - }, - }); -} - -function tooltipRegels(d, prijs) { - const regels = [fmtBasePrice(prijs)]; - const bron = d.row ? bronNamen.get(d.row.providerId) : null; - regels.push(bron ? `${kindLabel(d.kind)} · ${bron}` : kindLabel(d.kind)); - if (d.kind === 'spot' && d.row) { - const moment = d.row.resolution === 'timestamp' ? d.row.observedAt : (d.row.updatedAt || d.row.createdAt); - if (moment) regels.push(t('priceHistory.tipMoment', { tijd: localDateParts(moment).time })); - const pct = v => (v == null ? '?' : `${v > 0 ? '+' : ''}${v.toLocaleString(localeTag(), { maximumFractionDigits: 2 })}%`); - if (d.deviation) regels.push(t('priceHistory.tipDeviation', { voor: pct(d.deviation.before), na: pct(d.deviation.after) })); - } - if (d.kind === 'carried') regels.push(t('priceHistory.provCarriedNote', { n: d.ageDays })); - return regels; -} - -const overlapt = (r, g) => r.from <= (g.until ?? g.untilDay) && r.until >= (g.from ?? g.fromDay); -function herkomstHtml(k, dagen) { - const { asset } = k; - const counts = provenanceCounts(dagen); - const telling = PROVENANCE_KINDS.filter(k => counts[k] > 0) - .map(k => `${esc(soortTelling(k, counts[k]))}`) - .join(''); - const kop = dagen.length - ? `
    ${esc(t('priceHistory.cardPeriod', { dagen: telTekst('dayCount', dagen.length) }))}${telling}
    ` - : `

    ${esc(t('priceHistory.cardNoPrices'))}

    `; - const dicht = CONFIG.PRICE_HISTORY.CLOSED_MARKET_DAYS[asset.kind] ?? 0; - const zwak = provenanceRuns(dagen) - .filter(r => !['close', 'live', 'manual'].includes(r.kind) && !(r.kind === 'carried' && r.days <= dicht)) - .reverse(); - if (!dagen.length) return kop; - if (!zwak.length) return `${kop}

    ${esc(t('priceHistory.provNoWeak'))}

    `; - const toelichting = r => { - const stuk = dagen.filter(d => d.day >= r.from && d.day <= r.until); - if (r.kind === 'carried') return t('priceHistory.provCarriedNote', { n: Math.max(...stuk.map(d => d.ageDays)) }); - if (r.kind !== 'spot') return ''; - const pcts = stuk.flatMap(d => [d.deviation?.before, d.deviation?.after]).filter(v => v != null); - if (!pcts.length) return ''; - const max = pcts.reduce((a, b) => (Math.abs(b) > Math.abs(a) ? b : a)); - return t('priceHistory.provSpotNote', { pct: `${max > 0 ? '+' : ''}${max.toLocaleString(localeTag(), { maximumFractionDigits: 2 })}%` }); - }; - const bronVan = r => { - const namen = [...new Set(dagen.filter(d => d.day >= r.from && d.day <= r.until && d.row) - .map(d => bronNamen.get(d.row.providerId)).filter(Boolean))]; - return namen.length ? esc(namen.join(', ')) : dash; - }; - const naarGat = r => (r.kind === 'none' && [...k.gaps, ...k.ignored].some(g => overlapt(r, g)) - ? `` : ''); - const rijen = zwak.map(r => ` - ${esc(r.days === 1 ? r.from : t('priceHistory.provRange', { van: r.from, tot: r.until }))} - ${esc(kindLabel(r.kind))} - ${r.days} - ${bronVan(r)} - ${esc(toelichting(r))} - ${naarGat(r)} - `).join(''); - return `
    ${kop} -
    - - - - - - - - - ${rijen} -
    ${esc(t('priceHistory.provColPeriod'))}${esc(t('priceHistory.provColKind'))}${esc(t('priceHistory.provColDays'))}${esc(t('priceHistory.provColSource'))}${esc(t('priceHistory.provColNote'))}
    `; -} - -async function bronPaneel(el, panel, k, kop) { - const { asset } = k; - const regels = k.bevindingen.map(b => { - const tekst = t(`priceHistory.diag_${b.code}${b.code === 'limitReached' && b.severity !== 'problem' ? 'Fallback' : ''}`, - { namen: (b.names || []).join(', '), symbool: asset.symbol }); - const voorstel = b.proposal - ? `
    ${esc(t('priceHistory.diagProposal', { naam: b.proposal.providerName }))}
    ` : ''; - return `
    ${meldingHtml({ severity: b.severity, tekst })}${voorstel}
    `; - }).join(''); - panel.innerHTML = `${kop}${regels}
    `; - const host = panel.querySelector('[data-ph-matrix]'); - host.innerHTML = matrixCardHtml(asset, await loadMatrixContext(), { title: false }); - wireMatrix(host, () => naWijziging(el, asset.id, 'source')); -} - -function controleHtml({ verdacht }) { - const maat = c => (c.factor != null ? t('priceHistory.checkFactor', { n: c.factor }) - : c.afwijkingProcent != null ? t('priceHistory.checkShare', { n: c.afwijkingProcent }) - : c.verschilProcent != null ? t('priceHistory.checkShare', { n: c.verschilProcent }) : ''); - const bron = r => (r.provider_name || [r.low_provider_name, r.high_provider_name].filter(Boolean).join(' / ')); - return verdacht.map(({ kind, rows }, ki) => ` -
    -
    - ${esc(t(`health.kind.${kind}`))} - -
    -

    ${esc(t(`health.why.${kind}`))}

    -
    ${rows.map(({ row, counts }, ri) => ` -
    - ${esc(dayNl(localDateParts(row.observedAt).date))} · ${esc(bron(row))} - - ${esc(maat(counts || {}))} - - -
    `).join('')}
    -
    `).join('') + `

    ${esc(t('priceHistory.checkHint'))}

    `; -} - -let koersFilter = null; -let koersFocus = null; - -const dagVan = row => row.observedAt.slice(0, 10); -function filterVoor(rows) { - const ids = new Set(rows.filter(r => r.row.priceHistoryId != null).map(r => r.row.priceHistoryId)); - const dagen = new Set(rows.filter(r => r.row.priceHistoryId == null).map(r => dagVan(r.row))); - return r => ids.has(r.id) || (r.resolution === 'day' && dagen.has(dagVan(r))); -} - -function wireControle(el, panel, k) { - const naarKoersen = () => mountDetailTabs(el, k.asset.id, 'prices'); - panel.querySelectorAll('[data-check-kind]').forEach(b => b.onclick = () => { - const { kind, rows } = k.verdacht[Number(b.dataset.checkKind)]; - koersFilter = { label: t('priceHistory.checkFiltered', { soort: t(`health.kind.${kind}`), n: rows.length }), match: filterVoor(rows) }; - naarKoersen(); - }); - panel.querySelectorAll('[data-check-row]').forEach(b => b.onclick = () => { - const [ki, ri] = b.dataset.checkRow.split(':').map(Number); - const r = k.verdacht[ki].rows[ri]; - if (r.row.priceHistoryId != null) koersFocus = r.row.priceHistoryId; - else koersFilter = { label: t('priceHistory.checkFilteredDay', { dag: dagVan(r.row) }), match: filterVoor([r]) }; - naarKoersen(); - }); -} - -function koersenPaneel(el, panel, k, kop) { - const filter = koersFilter - ? `
    ${esc(koersFilter.label)} -
    ` - : ''; - panel.innerHTML = kop + filter + '
    '; - panel.querySelector('[data-clear-filter]')?.addEventListener('click', () => { - koersFilter = null; - mountDetailTabs(el, k.asset.id, 'prices'); - }); - buildTable(el, panel.querySelector('[data-ph-table]'), k.asset); -} - -function voortgang(panel) { - const box = panel.querySelector('[data-confirm]'); - box.hidden = false; - box.innerHTML = `
    ${esc(t('priceHistory.gapBusy'))}
    -
    - -
    `; - return box.querySelector('[data-stop]'); -} - -const gatKnop = (attr, i, label, icoon) => - ``; - -let gatFocus = null; - -async function gatenPaneel(el, panel, k, kop) { - const dagen = k.gaps.reduce((s, g) => s + g.days, 0); - const focus = gatFocus; - gatFocus = null; - const inFocus = g => (focus && overlapt(focus, g) ? ' is-focus' : ''); - const expand = await expanders('priceHistory', { ignored: false, absent: false }); - const kopregel = k.gaps.length ? ` -
    - ${esc(t('priceHistory.gapCardSummary', { gaten: telTekst('gapCount', k.gaps.length), dagen: telTekst('dayCount', dagen) }))} - - - - -
    ` : `

    ${esc(t('priceHistory.gapNone'))}

    `; - const lijst = `
    ${k.gaps.map((g, i) => ` -
    - ${esc(t('priceHistory.gapLine', { van: g.from, tot: g.until, n: g.days }))} - ${gatKnop('data-gap', i, t('priceHistory.gapFill'), REFRESH)}${gatKnop('data-gap-ignore', i, t('priceHistory.gapIgnore'), EYE_OFF)} -
    `).join('')}
    `; - const openVoorFocus = k.ignored.some(g => inFocus(g)) && !expand.open('ignored'); - const genegeerd = k.ignored.length ? ` -
    - ${CHEVRON_RIGHT}${esc(t('priceHistory.tabIgnored'))} (${k.ignored.length}) -
    ${k.ignored.map(g => ` -
    - ${esc(t('priceHistory.gapLine', { van: g.fromDay, tot: g.untilDay, n: daysIncl(g.fromDay, g.untilDay) }))} - ${gatKnop('data-unignore', g.id, t('priceHistory.gapUnignore'), EYE)} -
    `).join('')}
    -
    ` : ''; - const afwezig = k.absent.length ? ` -
    - ${CHEVRON_RIGHT}${esc(t('priceHistory.tabAbsent'))} (${k.absent.length}) -

    ${esc(t('priceHistory.absentExplain'))}

    -
    ${k.absent.map((g, i) => ` -
    - ${esc(g.days === 1 ? t('priceHistory.absentLineOne', { bron: g.providerName, dag: g.fromDay }) - : t('priceHistory.absentLine', { bron: g.providerName, van: g.fromDay, tot: g.untilDay, dagen: telTekst('dayCount', g.days) }))} - ${gatKnop('data-absent-forget', i, t('priceHistory.absentForget'), CLOSE)} -
    `).join('')}
    -
    ` : ''; - panel.innerHTML = `${kop}${kopregel}${lijst}${genegeerd}${afwezig}`; - panel.querySelector('.gap-row.is-focus')?.scrollIntoView({ block: 'center' }); - expand.bind(panel); - panel.querySelector('[data-gap-all]')?.addEventListener('click', () => fillGaps(el, panel, k, k.gaps)); - panel.querySelectorAll('[data-gap]').forEach(b => b.onclick = () => fillGaps(el, panel, k, [k.gaps[Number(b.dataset.gap)]])); - panel.querySelectorAll('[data-gap-ignore]').forEach(b => b.onclick = () => negeer(el, k, [k.gaps[Number(b.dataset.gapIgnore)]])); - panel.querySelector('[data-gap-ignore-all]')?.addEventListener('click', () => negeer(el, k, k.gaps)); - panel.querySelectorAll('[data-unignore]').forEach(b => b.onclick = async () => { - let melding = null; - try { await unignorePriceGap(Number(b.dataset.unignore)); } catch (e) { melding = e.message; } - await naWijziging(el, k.asset.id, 'gaps', melding); - }); - panel.querySelectorAll('[data-absent-forget]').forEach(b => b.onclick = async () => { - const g = k.absent[Number(b.dataset.absentForget)]; - let melding = null; - try { await deletePriceAbsences({ assetId: g.assetId, providerId: g.providerId, from: g.fromDay, until: g.untilDay }); } - catch (e) { melding = e.message; } - await naWijziging(el, k.asset.id, 'gaps', melding); - }); -} - -async function negeer(el, k, gaps) { - const vraag = gaps.length === 1 ? t('priceHistory.gapIgnoreConfirm') : t('priceHistory.gapIgnoreAllConfirm', { n: gaps.length }); - const label = t(gaps.length === 1 ? 'priceHistory.gapIgnore' : 'priceHistory.gapIgnoreAll'); - if (!(await dialog.confirmOver({ title: label, message: vraag, confirmLabel: label }))) return; - let melding = null; - try { - for (const g of gaps) await ignorePriceGap({ assetId: k.asset.id, from: g.from, until: g.until }); - } catch (e) { melding = e.message; } - await naWijziging(el, k.asset.id, 'gaps', melding); -} - -async function fillGaps(el, panel, k, gaps) { - const { asset } = k; - if (!gaps || !gaps.length) return; - const reeks = await primaryProvider(asset, 'daily_history'); - const perDatum = await primaryProvider(asset, 'history_point'); - if (!reeks && !perDatum) { - detailMelding = t('priceHistory.gapNoSource', { asset: asset.symbol }); - mountDetailTabs(el, asset.id, 'gaps'); - return; - } - const dagen = gaps.reduce((s, g) => s + daysToAsk(asset, g.from, g.until), 0); - const vraag = reeks && perDatum ? t('priceHistory.gapConfirmBoth', { reeks: reeks.name, bron: perDatum.name, n: dagen }) - : reeks ? t('priceHistory.gapConfirmSeries', { reeks: reeks.name }) - : t('priceHistory.gapConfirmPoint', { bron: perDatum.name, n: dagen }); - if (!(await dialog.confirmOver({ title: t('priceHistory.gapFill'), message: vraag, confirmLabel: t('priceHistory.gapFill') }))) return; - - panel.querySelectorAll('button').forEach(b => { b.disabled = true; }); - const btn = voortgang(panel); - const stop = new AbortController(); - btn.disabled = false; - btn.onclick = () => { stop.abort(); btn.disabled = true; }; - let stopped = false, limitReached = false, fout = null; - try { - for (let i = 0; i < gaps.length && !stop.signal.aborted; i++) { - btn.textContent = gaps.length > 1 ? t('priceHistory.gapStopProgress', { i: i + 1, n: gaps.length }) : t('priceHistory.gapStop'); - const uit = await fillClosesFor(asset, gaps[i].from, gaps[i].until, { signal: stop.signal }); - if (uit.stopped) stopped = true; - if (uit.limitReached) { limitReached = true; break; } - } - if (stop.signal.aborted) stopped = true; - } catch (e) { - fout = e.message; - } - let resterend = []; - try { - resterend = (await listPriceGaps()).rows - .filter(g => g.assetId === asset.id && gaps.some(h => g.from <= h.until && g.until >= h.from)); - } catch { } - const rest = resterend.reduce((s, g) => s + g.days, 0); - let waarom = ''; - if (rest && stopped) waarom = t('priceHistory.gapStopped'); - else if (rest && limitReached) waarom = t('priceHistory.gapLimit'); - else if (rest) { - if (perDatum) waarom = t('priceHistory.gapWhyPoint', { bron: perDatum.name }); - else { - let begin = null; - try { - for (const r of await listPriceHistory(asset.id)) { - const dag = r.observedAt.slice(0, 10); - if (r.providerId === reeks.id && r.resolution === 'day' && (!begin || dag < begin)) begin = dag; - } - } catch { } - if (!begin) waarom = t('priceHistory.gapWhySeriesEmpty', { reeks: reeks.name }); - else if (resterend.some(g => g.from < begin)) waarom = t('priceHistory.gapWhySeries', { reeks: reeks.name, begin }); - else waarom = t('priceHistory.gapWhySeriesHole', { reeks: reeks.name, n: rest }); - } - } - const melding = fout || (!rest ? t('priceHistory.gapFilled', { asset: asset.symbol }) - : `${t('priceHistory.gapRemaining', { asset: asset.symbol, n: rest })} ${waarom}`); - await naWijziging(el, asset.id, 'gaps', melding); -} - -async function tableRows(asset) { - const rijen = await listAllPriceHistory({ assetId: asset.id }); - return koersFilter ? rijen.filter(koersFilter.match) : rijen; -} - -let alleAssets = []; -const assetVan = id => alleAssets.find(a => a.id === Number(id)) || null; - -const eenheidVan = asset => (asset ? priceUnitLabel(asset) : ''); -function eenheidOpts(a) { - if (!a || !isMetal(a)) return []; - return [a.unit, a.subunit].filter(Boolean).map(u => ({ value: u, label: u })); -} -function momentVan(vals) { - if (vals.resolution !== 'timestamp') return String(vals.date || ''); - const tijd = String(vals.time || '00:00'); - return new Date(`${vals.date}T${tijd}`).toISOString(); -} - -async function buildTable(el, host, asset) { - const tabelAsset = () => asset; - const columns = [ - { key: 'date', label: t('priceHistory.colDate'), sortable: true, sortValue: r => r.observedAt, render: r => r.observedAt ? esc(dayNl(displayDate(r))) : dash, group: { value: r => displayDate(r), label: v => dayNl(v), order: 'desc' }, - edit: { type: 'date', sticky: true, value: r => r && r.observedAt ? displayDate(r) : todayIso() } }, - { key: 'time', label: t('priceHistory.colTime'), sortable: true, sortValue: r => r.observedAt, render: r => r.resolution === 'timestamp' ? esc(localDateParts(r.observedAt).time) : dash, - edit: { type: 'time', visible: vals => vals.resolution === 'timestamp', - value: r => r && r.resolution === 'timestamp' ? localDateParts(r.observedAt).time : '00:00' } }, - { key: 'resolution', label: t('priceHistory.colResolution'), sortable: true, sortValue: r => r.resolution, render: r => r.resolution ? esc(resLabel(r.resolution)) : dash, group: { value: r => resLabel(r.resolution), label: v => v }, - edit: { type: 'select', reactive: true, sticky: true, value: r => r ? r.resolution : 'day', - options: () => ENUMS.PRICE_RESOLUTION.map(v => ({ value: v, label: resLabel(v) })) } }, - { key: 'source', label: t('priceHistory.colIntegration'), sortable: true, sortValue: r => r.provider_name, render: r => r.provider_name ? esc(r.provider_name) : dash, group: { value: r => r.provider_name, label: v => v } }, - { key: 'fiatPrice', label: baseCurrency(), align: 'num', sortable: true, sortValue: r => r.fiatPrice ?? -1, - render: r => r.fiatPrice != null ? fmtBasePrice(priceFromBase(r.fiatPrice, assetVan(r.assetId))) : dash, - edit: { type: 'number', attrs: { min: 0, step: 'any' }, - value: r => (r && r.fiatPrice != null ? priceFromBase(r.fiatPrice, assetVan(r.assetId)) : '') } }, - { key: 'priceUnit', label: t('priceHistory.colUnit'), - render: r => r.assetId ? esc(eenheidVan(assetVan(r.assetId))) : dash, - edit: { type: 'select', sticky: true, visible: () => isMetal(tabelAsset()), - options: () => eenheidOpts(tabelAsset()), value: () => eenheidVan(tabelAsset()) } }, - { key: 'updated', label: t('priceHistory.colUpdated'), sortable: true, sortValue: r => r.updatedAt || '', render: r => r.updatedAt ? esc(fmtDateTime(Math.floor(Date.parse(r.updatedAt) / 1000))) : dash }, - ]; - phTable = renderTable(host, { - columns, - rows: await tableRows(asset), - idKey: 'id', - ...(await tableViewCfg('prijsinfo', { key: 'date', dir: 'desc' })), - noneLabel: t('table.none'), - collapsibleGroups: true, - searchLabel: t('priceHistory.search'), - emptyText: t('priceHistory.noPoints'), - onDelete: id => onDeleteRow(el, asset, id), - onCreate: v => onCreateRow(el, asset, v), - extraActions: [{ key: 'refresh', label: t('priceHistory.refresh') }], - onAction: (key, id) => { if (key === 'refresh') onRefreshRow(el, asset, id); }, - }); - if (koersFocus != null) { phTable.focusRow(koersFocus); koersFocus = null; } -} - -async function naRijWijziging(el, asset, locate = null) { - if (phTable) phTable.refresh(await tableRows(asset), locate != null ? { locate } : undefined); - document.dispatchEvent(new CustomEvent('price-gaps-changed')); - await renderCards(el); - await laadDetail(asset); - tekenDetailGrafiek(asset).catch(() => {}); -} - -async function onCreateRow(el, asset, vals) { - const id = await addManualPricePoint({ - assetId: asset.id, - observedAt: momentVan(vals), - fiatPrice: vals.fiatPrice, - resolution: vals.resolution || 'day', - unit: vals.priceUnit || null, - }); - await naRijWijziging(el, asset, id); -} - -async function onDeleteRow(el, asset, id) { - if (!(await dialog.confirmOver({ message: t('priceHistory.confirmDeletePoint'), danger: true }))) return; - try { await deleteTableRow('PriceHistory', id); } catch { } - await naRijWijziging(el, asset); -} - -async function onRefreshRow(el, asset, id) { - const row = (await tableRows(asset)).find(r => r.id === id); - if (!row) return; - const a = { id: row.assetId, symbol: row.asset_symbol }; - const dateKey = row.observedAt.slice(0, 10); - try { - const bron = row.provider_key; - if (row.resolution === 'day') { - const pt = await fetchDayPoint(bron, a, dateKey); - if (pt) await upsertPriceHistory(a.id, [pt], bron, 'day'); - } else if (dateKey === todayIso()) { - const sp = await fetchSpotPoint(bron, a); - if (sp) await upsertPriceHistory(a.id, [sp], bron, 'timestamp'); - } - } catch { } - await naRijWijziging(el, asset); -} diff --git a/client/pages/system.js b/client/pages/system.js index c61087d..927b3f8 100644 --- a/client/pages/system.js +++ b/client/pages/system.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:c54ac534bce5953f6b0bb207fdc1338feba7f454198f189ef3b97c5830760c48 +// Generated, do not edit. sha256:c74d68370e5fcfc4f6009b2cf9bbe65c4f4f227eb216c413ea6ff5daeae0f4fa import { t } from '../i18n/index.js'; import { getPref, setPref } from '../data/preferences.js'; import { SYSTEM_PAGE, targetHash } from '../../shared/config.js'; @@ -11,6 +11,7 @@ import * as assetsPage from './assets.js'; import * as connections from './connections.js'; import * as aiPage from './ai.js'; import * as licensePage from './license.js'; +import * as portfoliosPage from './portfolios.js'; export const title = () => t('nav.system'); @@ -18,6 +19,7 @@ const ROUTE = SYSTEM_PAGE.ROUTE; const TABS = SYSTEM_PAGE.TABS; const PREF_SCOPE = ROUTE; +registerSystemTab({ id: TABS.PORTFOLIOS, render: panel => portfoliosPage.render(panel) }); registerSystemTab({ id: TABS.SETTINGS, render: panel => settings.render(panel) }); registerSystemTab({ id: TABS.ASSETS, render: panel => assetsPage.render(panel) }); registerSystemTab({ id: TABS.ACCOUNTS, render: panel => accountsPage.render(panel) }); diff --git a/client/pages/valuations.js b/client/pages/valuations.js index c0955ea..8c05607 100644 --- a/client/pages/valuations.js +++ b/client/pages/valuations.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:84e73291cc02df3176d4ba8acbc3d3f1b844080d320978a75a2af8c8bde70e30 +// Generated, do not edit. sha256:064fe66c277773dbc29669a7a0cdf7abab018774c71a0f8e1d2a5cceea3a4d22 import { listSelectableAccounts } from '../data/accounts.js'; import { dayNl, localTime, toUtcIso } from '../../shared/time.js'; import { listAssets, listBookableAssets } from '../data/assets.js'; @@ -18,7 +18,6 @@ import { ensurePriceHistoryFor, historicalPointForVia, primarySourceKey } from ' import { bookDifference, acceptDifference } from '../actions/valuation-widget.js'; import { TARGETS, targetHash } from '../../shared/config.js'; import { emptyStateHtml } from '../ui/empty-state.js'; -import { capacityCfg } from '../ui/lock.js'; import { setPageHint } from '../ui/page-hint.js'; let tableApi = null; @@ -146,11 +145,9 @@ async function buildTable(el) { const toPayload = valuationPayload; const rijen = await rows(); - let used = rijen.length; - const reload = async () => { const r = await rows(); used = r.length; tableApi.refresh(r); }; + const reload = async () => tableApi.refresh(await rows()); tableApi = renderTable(el.querySelector('#tbl'), { columns, rows: rijen, - ...capacityCfg('valuations', () => used), ...(await tableViewCfg('valuations', { key: 'valuedOn', dir: 'desc' }, onlyAccount != null ? 'assetId' : null)), emptyText: t('valuations.none'), noneLabel: t('table.none'), @@ -161,9 +158,7 @@ async function buildTable(el) { saveLabel: t('trades.save'), cancelLabel: t('trades.cancel'), onCreate: async v => { const id = await createValuation(await toPayload(v, null)); - const r = await rows(); - used = r.length; - tableApi.refresh(r, { locate: id }); + tableApi.refresh(await rows(), { locate: id }); }, onSave: async (id, v) => { const ex = (await listValuations()).find(x => x.id === id); diff --git a/client/portfolio.js b/client/portfolio.js index 2993055..191a0be 100644 --- a/client/portfolio.js +++ b/client/portfolio.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:0b8a580ca944f426e2e3aa4800988bad2046937a8c0409e4dceebf09b6b3e9f7 +// Generated, do not edit. sha256:00050770841127bfd8758b2ba6a84c8e7619c5e92ca5091e3c1961f13783da53 import { CONFIG } from '../shared/config.js'; import { t } from './i18n/index.js'; import { serverFoutTekst } from './data/_rpc.js'; @@ -40,7 +40,8 @@ export async function refreshActivePortfolio() { const r = await fetch('/api/portfolios'); if (!r.ok) return cachedPortfolioName(); const uit = await r.json(); - toonNaam(locked('portfolios') ? '' : uit.actief || ''); + const enige = locked('portfolios') && (uit.portefeuilles || []).length < 2; + toonNaam(enige ? '' : uit.actief || ''); if (opgebouwdMet === null) opgebouwdMet = uit.actief || ''; return uit.actief || ''; } catch { diff --git a/client/price/btc-explorer.js b/client/price/btc-explorer.js index ad88925..1b1ed16 100644 --- a/client/price/btc-explorer.js +++ b/client/price/btc-explorer.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:e9ea9293b00980ab0270b38c345d130a439421cd662f57bea63c105e66a1587f +// Generated, do not edit. sha256:f1a362d8f5a38865a6fcd067548c9a9a2cf682e9141ad905ab0415dc770a62a9 import { CONFIG } from '../../shared/config.js'; import { activeConnection } from '../data/connections.js'; import { t } from '../i18n/index.js'; @@ -8,12 +8,11 @@ export async function explorerBase() { } const HTTP_TIMEOUT_MS = 12000; -const HTTP_RETRIES = 1; -const HTTP_BACKOFF_MS = 800; +const HTTP_BACKOFF_MS = [2000, 5000, 10000]; export async function fetchJson(url, label, options = {}) { let laatste; - for (let poging = 0; poging <= HTTP_RETRIES; poging++) { - if (poging) await new Promise(r => setTimeout(r, HTTP_BACKOFF_MS * poging)); + for (let poging = 0; poging <= HTTP_BACKOFF_MS.length; poging++) { + if (poging) await new Promise(r => setTimeout(r, HTTP_BACKOFF_MS[poging - 1])); const ctrl = new AbortController(); const timer = setTimeout(() => ctrl.abort(), HTTP_TIMEOUT_MS); try { diff --git a/client/ui/activity.js b/client/ui/activity.js index bc62feb..7fd0403 100644 --- a/client/ui/activity.js +++ b/client/ui/activity.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:88f1ff40757f8e5095efe909c3a45c2f437406121459c4091bd0b4d3c80eac8c +// Generated, do not edit. sha256:69057ab8eda9ab21e21cc877b9070be1e08c5b047758e64ec4c5cd772fa0ac07 import { localDate } from '../../shared/time.js'; const DAY_MS = 86400000; @@ -53,7 +53,7 @@ export function heartbeat(items, todayIso, fromIso = null) { const last = Math.max(...byDay.keys(), today); const first = Math.min(from ?? Math.min(...byDay.keys(), today) - DAY_MS, last - DAY_MS); const points = []; - for (let x = first; x <= last; x += DAY_MS) { + for (let x = first; x <= last + DAY_MS; x += DAY_MS) { const day = byDay.get(x) || []; const up = day.filter(i => i.dir > 0).length; const down = day.filter(i => i.dir < 0).length; diff --git a/client/ui/attention-sources.js b/client/ui/attention-sources.js index dd494d5..c546d5a 100644 --- a/client/ui/attention-sources.js +++ b/client/ui/attention-sources.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:51b53dc3f01e74bb7f221f45ce7f2b9b6f6a164a12cedc96e33ad4f1b1b701a0 +// Generated, do not edit. sha256:a36be83c24f4e2c2e73be5d6705dd33c4759901705776f21398caba72366f10a import { currentNotifications } from '../data/notifications.js'; import { countAiToolCallsSince } from '../data/ai-audit.js'; import { getPref } from '../data/preferences.js'; @@ -12,6 +12,7 @@ import { CONFIG, TARGETS, NOTIFICATION_TARGETS, SOURCE_ENDPOINTS, targetHash, ta import { registerAttention } from './attention.js'; import { appSetting, baseCurrency } from '../app-settings.js'; import { licenseChangedSinceSeen } from '../license.js'; +import { placeAvailable } from '../routes.js'; async function integrationsNeedingKey() { const rijen = await listProviders(); @@ -96,6 +97,7 @@ if (typeof document !== 'undefined') { document.addEventListener('price-gaps-changed', () => { gapsCache = { at: 0, total: 0 }; }); } async function priceGaps() { + if (!placeAvailable(TARGETS.PRICE_HISTORY)) return []; if (Date.now() - gapsCache.at > GAPS_TTL_MS) { try { gapsCache = { at: Date.now(), total: (await listPriceGaps()).total }; } catch { return []; } diff --git a/client/ui/blur.js b/client/ui/blur.js index b265e22..1a350fa 100644 --- a/client/ui/blur.js +++ b/client/ui/blur.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:3f4bf112e28f009a738272dd18bef14d5e6736a31c2f3e1f6e434733f909d6ea +// Generated, do not edit. sha256:93e679e11f5329a380a996f2d99d603c26410a0b331dfefcb1da78dc2058cc17 import { appSetting, setAppSetting } from '../app-settings.js'; import { t } from '../i18n/index.js'; import { EYE, EYE_OFF } from './icons.js'; @@ -37,6 +37,14 @@ async function setOn(on) { function onActivity() { if (!isOn()) armIdle(); } +function onSpace(e) { + if (e.key !== ' ' || e.repeat || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return; + if (e.target !== document.body && e.target !== document.documentElement) return; + if (document.querySelector('.nav-edit-toggle.is-on')) return; + e.preventDefault(); + setOn(!isOn()); +} + export function initPrivacyBlur(hostEl) { btn = document.createElement('button'); btn.type = 'button'; @@ -52,5 +60,6 @@ export function initPrivacyBlur(hostEl) { for (const ev of ['pointerdown', 'keydown', 'wheel', 'touchstart']) { document.addEventListener(ev, onActivity, { passive: true }); } + document.addEventListener('keydown', onSpace); document.addEventListener('settings-changed', () => { if (!isOn()) armIdle(); }); } diff --git a/client/ui/hint.js b/client/ui/hint.js index 432498f..74303e4 100644 --- a/client/ui/hint.js +++ b/client/ui/hint.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:618e9d10819427320df9cea13ee26eca05db3121f4e69b541d2a8a431e85957a +// Generated, do not edit. sha256:2cb6efb613791caa2b77487d43b44b223a6a6e006b7a374e8ed1b4c6e8f50169 import { esc } from './escape.js'; const MOUNT = 'page-hint'; @@ -47,8 +47,24 @@ function watchFit(mount) { panel.classList.remove('is-wide'); if (panel.scrollHeight > panel.clientHeight + 1) panel.classList.add('is-wide'); }; + const close = () => { + const open = mount.querySelector('.hint.is-open'); + open?.classList.remove('is-open'); + open?.querySelector('.hint-btn')?.setAttribute('aria-expanded', 'false'); + }; mount.addEventListener('pointerenter', fit); mount.addEventListener('focusin', fit); + mount.addEventListener('click', (e) => { + const btn = e.target.closest?.('.hint-btn'); + if (!btn) return; + const hint = btn.closest('.hint'); + if (hint.classList.contains('is-open')) { close(); return; } + hint.classList.add('is-open'); + btn.setAttribute('aria-expanded', 'true'); + fit(); + }); + document.addEventListener('click', (e) => { if (!mount.contains(e.target)) close(); }); + document.addEventListener('keydown', (e) => { if (e.key === 'Escape') close(); }); } function row(r) { diff --git a/client/ui/icons.js b/client/ui/icons.js index d1e4837..bf5511f 100644 --- a/client/ui/icons.js +++ b/client/ui/icons.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:06627f5d01d37034867aaf9d6b234f888eb4b99f4ecd0e53cb5df7c45bce718a +// Generated, do not edit. sha256:0e4fc635bcc50c839bba37ef206c2c659c8dcc17c03278176cb0be588b69506a export const CHEVRON = ''; export const CHEVRON_RIGHT = ''; @@ -36,4 +36,6 @@ export const CHECK = ''; +export const IMAGE = ''; + export const COPY = ''; diff --git a/client/ui/source-matrix.js b/client/ui/source-matrix.js deleted file mode 100644 index 3a229e4..0000000 --- a/client/ui/source-matrix.js +++ /dev/null @@ -1,147 +0,0 @@ -// Generated, do not edit. sha256:e64fde93e62c826f1ddca6217aab270e6309de4394ce5cb0e258a0e0fdb72d5c -import { t } from '../i18n/index.js'; -import { listPriceSource, setPriceSourceRank, clearPriceSourceCell, confirmPriceSourceCell } from '../data/price-source.js'; -import { listProviders, getProvider } from '../data/providers.js'; -import { rateSourceFor } from '../price/providers.js'; -import { serviceCoverage } from '../data/market.js'; -import { SOURCE_CAPABILITIES, SOURCE_ENDPOINTS } from '../../shared/config.js'; -import { baseCurrency, appSetting } from '../app-settings.js'; -import { assetLabelHtml } from './asset-label.js'; -import { esc } from './escape.js'; -import * as dialog from './dialog.js'; - -const endpointsUnder = (p, cap) => (p.endpoints || []).filter(e => SOURCE_ENDPOINTS[cap].includes(e.capability)); -const answers = (p, cap) => endpointsUnder(p, cap).length > 0; - -function quoteOf(p, cap) { - const e = endpointsUnder(p, cap).find(x => x.quoteCurrency && x.quoteCurrency !== baseCurrency()); - return e ? e.quoteCurrency : null; -} -const currenciesOf = p => [...new Set(SOURCE_CAPABILITIES.map(c => quoteOf(p, c)).filter(Boolean))]; - -export async function loadMatrixContext() { - const alle = (await Promise.all((await listProviders()).map(p => getProvider(p.key)))).filter(Boolean); - const providers = alle.filter(p => !p.isSystem); - const cell = new Map(); - for (const r of await listPriceSource()) { - if (r.rank == null) continue; - cell.set(`${r.assetId}|${r.capability}|${r.providerId}`, - { rank: r.rank, proposed: r.status === 'proposed', own: r.status === 'manual' }); - } - const rateSource = new Map(); - for (const p of providers) { - for (const c of currenciesOf(p)) if (!rateSource.has(c)) rateSource.set(c, await rateSourceFor(c)); - } - return { alle, providers, cell, rateSource, service: await serviceContext() }; -} - -async function serviceContext() { - let mode = 'off'; - try { mode = appSetting('market_spot'); } catch { } - if (mode === 'off') return { mode, covered: new Set() }; - try { - const r = await serviceCoverage(); - return { mode, covered: new Set(r.status === 'ok' ? r.assetIds : []) }; - } catch { return { mode, covered: new Set() }; } -} - -export function serviceOrder(chosen, mode) { - const byRank = [...chosen].sort((x, y) => x.rank - y.rank); - const order = mode === 'first' - ? [...byRank.filter(c => c.own), 'service', ...byRank.filter(c => !c.own)] - : [...byRank, 'service']; - const ranks = new Map(); - let service = null; - order.forEach((c, i) => { if (c === 'service') service = i + 1; else ranks.set(c.providerId, i + 1); }); - return { ranks, service }; -} - -const marker = (ctx, v) => `${esc(v)}`; -const offTitle = p => (p.isActive ? '' : ` title="${esc(t('integrations.inactiveNoEffect'))}"`); - -function kopVan(a, stand, title = true) { - if (!title && !stand) return ''; - return `
    - ${title ? `
    ${assetLabelHtml(a)}${esc(t('enums.asset_kind.' + a.kind))}
    ` : ''} - ${stand ? `
    ${esc(stand)}
    ` : ''} -
    `; -} - -export function matrixCardHtml(a, ctx, { title = true } = {}) { - const cols = ctx.providers.filter(p => (p.coverage || []).includes(a.symbol)); - const svc = ctx.service && ctx.service.mode !== 'off' && ctx.service.covered.has(a.id); - if (!cols.length && !svc) { - const systeem = ctx.alle.find(p => p.isSystem && (p.coverage || []).includes(a.symbol)); - const tekst = systeem ? esc(t('integrations.systemSource').replace('{naam}', systeem.name)) : esc(t('integrations.noCoverage')); - return `
    ${kopVan(a, '', title)}
    ${tekst}
    `; - } - const svcTitle = svc ? esc(t('integrations.mxServiceHint_' + ctx.service.mode)) : ''; - const naamKop = `${cols.map(p => - `${esc(p.name)}`).join('')}${ - svc ? `Atreides Services` : ''}`; - const muntKop = `${cols.map(p => - `${currenciesOf(p).map(v => marker(ctx, v)).join(' ')}`).join('')}${svc ? '' : ''}`; - const head = naamKop + muntKop; - const rank = (c, p, shown = c.rank) => - `${shown}`; - let open = 0, voorstellen = 0; - const leeg = []; - const rows = SOURCE_CAPABILITIES.filter(cap => cols.some(p => answers(p, cap)) || (svc && cap === 'spot')); - const body = rows.map(cap => { - const metDienst = svc && cap === 'spot'; - const volgorde = metDienst - ? serviceOrder(cols.map(p => ({ providerId: p.id, ...ctx.cell.get(`${a.id}|${cap}|${p.id}`) })) - .filter(c => c.rank != null), ctx.service.mode) - : null; - if (!metDienst && !cols.some(p => ctx.cell.has(`${a.id}|${cap}|${p.id}`))) leeg.push(t('integrations.sourceCap.' + cap)); - const dienstCel = svc - ? (metDienst - ? `${volgorde.service}` - : ``) - : ''; - const cells = cols.map(p => { - if (!answers(p, cap)) return ``; - const c = ctx.cell.get(`${a.id}|${cap}|${p.id}`); - const valuta = quoteOf(p, cap); - if (valuta && !ctx.rateSource.get(valuta) && !c) { - return ``; - } - if (!c) open++; - else if (c.proposed) voorstellen++; - const inner = c ? rank(c, p, volgorde ? volgorde.ranks.get(p.id) : c.rank) : `+`; - return `${inner}`; - }).join(''); - return `${esc(t('integrations.sourceCap.' + cap))}${cells}${dienstCel}`; - }).join(''); - const stand = [ - leeg.length ? t('integrations.mxToSetUp', { wat: leeg.join(' en ') }) : '', - voorstellen ? t(voorstellen === 1 ? 'integrations.mxProposalsOne' : 'integrations.mxProposalsMany', { n: voorstellen }) : '', - open ? t(open === 1 ? 'integrations.mxOpenOne' : 'integrations.mxOpenMany', { n: open }) : t('integrations.mxAllChosen'), - ].filter(Boolean).join(' · '); - return `
    ${kopVan(a, stand.charAt(0).toUpperCase() + stand.slice(1), title)}
    ${head}${body}
    `; -} - -export function wireMatrix(host, redraw) { - host.querySelectorAll('.mx-cell').forEach(td => td.onclick = async () => { - const d = td.dataset; - const a = Number(d.a), p = Number(d.p); - try { - if (d.has === '1' && d.proposed === '1') await confirmPriceSourceCell(a, d.cap, p); - else if (d.has === '1') await clearPriceSourceCell(a, d.cap, p); - else await setPriceSourceRank(a, d.cap, p); - document.dispatchEvent(new CustomEvent('providers-changed')); - } catch (e) { dialog.alert({ title: t('dialog.error'), message: e.message }); } - await redraw(); - }); -} - -export function matrixLegendRows(ctx) { - const uit = ctx.providers.some(p => !p.isActive) - ? [{ sample: '1', text: esc(t('integrations.inactiveHint')) }] - : []; - const munten = [...ctx.rateSource].map(([v, via]) => ({ - sample: marker(ctx, v), - text: esc(via ? t('integrations.convertedVia', { naam: via.name, valuta: v, munt: baseCurrency() }) : t('integrations.noRateSource', { valuta: v })), - })); - return [...uit, ...munten]; -} diff --git a/client/wealth/return-view.js b/client/wealth/return-view.js index 0156142..29af713 100644 --- a/client/wealth/return-view.js +++ b/client/wealth/return-view.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:79d0944a46421ed3e71c6aff535ca9c3c77b373253595260dd7e749f587d9edd +// Generated, do not edit. sha256:1e2f6b41323ddf9ad9f82e4a351a8a2bf38460efa6a6ea846e58268ba7ab38e4 import { CONFIG } from '../../shared/config.js'; import { windowTwr, windowFactors } from './performance.js'; import { dailyResults, meetVenster, rollingWindows, seriesFor, windowResult } from './series.js'; @@ -32,6 +32,13 @@ export function returnLine(input = {}, venster = null) { return { amount: windowResult(input, venster), pct: windowTwr(input, venster), points }; } +export function flatLine(days, today) { + const n = Math.max(2, days); + const end = Date.parse(`${today}T00:00:00Z`); + const labels = Array.from({ length: n }, (_, k) => new Date(end - (n - 1 - k) * 86_400_000).toISOString().slice(0, 10)); + return { amount: 0, pct: 0, labels, points: labels.map((_, i) => ({ i, cumulative: 0, day: 0, pct: 0 })) }; +} + export function contributorsPerDay(reeks = {}, ids = [], venster = null, n = 3) { const out = new Map(); if (!venster || !ids || ids.length < 2) return out; diff --git a/client/widgets/return.js b/client/widgets/return.js index bec9c59..9ccab36 100644 --- a/client/widgets/return.js +++ b/client/widgets/return.js @@ -1,5 +1,5 @@ -// Generated, do not edit. sha256:ae0f941ec7a830f9f94ae85e37de1157b6e15f16cc2e9dc3f0c5c7243d3eaafd -import { listAssets } from '../data/assets.js'; +// Generated, do not edit. sha256:dbfabff3706a8f2f1755ee61d42f71fcabb5b42dd0ab60143a9e2b568cf13043 +import { listAssets, listBookableAssets } from '../data/assets.js'; import { listAccounts } from '../data/accounts.js'; import { getPref, setPref } from '../data/preferences.js'; import { t } from '../i18n/index.js'; @@ -11,8 +11,12 @@ import { rangeLabel, rangeCycleButton, wireRangeCycle } from '../ui/range-cycle. import { isOwnWealth } from '../../shared/wealth-scope.js'; import { ENUMS, TARGETS, targetHash } from '../../shared/config.js'; import { dagreeksVanNu } from '../wealth/series.js'; -import { periodChoices } from '../wealth/return-view.js'; +import { periodChoices, flatLine } from '../wealth/return-view.js'; import { lineForData, drawLine } from '../wealth/return-dialog.js'; +import { drawReturnChart } from '../wealth/return-chart.js'; +import { localDateNl } from '../../shared/time.js'; + +const localTodayIso = () => new Date().toISOString().slice(0, 10); const PREF_SCOPE = 'widget.return'; const RANGES = Object.freeze({ day: 1, week: 7, month: 30, year: 365, all: 0 }); @@ -62,14 +66,27 @@ export async function renderReturnWidget(host, instance) { const held = assets.filter(a => (reeks.perAsset?.get(a.id) || []).some(v => v > 0)); const periods = periodChoices(reeks.dagen?.length || 0, null); + const empty = !reeks.dagen?.length; const draw = async () => { const g = ++gen; const btn = host.querySelector('.range-cycle-btn'); if (btn) btn.textContent = rangeLabel(range); + if (empty) { + const flat = flatLine(RANGES[range] || RANGES.month, localTodayIso()); + amountEl.innerHTML = `${esc(fmtBaseSigned(0, colouredSigns()))}`; + pctEl.innerHTML = `${esc(fmtPct(0, { signs: colouredSigns() }))}`; + chart?.destroy(); + const canvas = host.querySelector('[data-return-chart]'); + const c = canvas ? await drawReturnChart(canvas, flat.points, flat.labels.map(d => localDateNl(`${d}T00:00:00Z`))).catch(() => null) : null; + if (g !== gen || !host.isConnected) { c?.destroy(); return; } + chart = c; + return; + } const venster = periods.find(p => p.key === PERIOD_OF[range])?.venster || null; const line = lineForData({ reeks, assets: held, data, venster }); + const tone = line.amount > 0.005 ? ' t-pos' : line.amount < -0.005 ? ' t-neg' : ''; amountEl.innerHTML = line.amount == null ? '-' - : `${esc(fmtBaseSigned(line.amount, 'both'))}`; + : `${esc(fmtBaseSigned(line.amount, colouredSigns()))}`; pctEl.innerHTML = line.pct == null ? '' : `${esc(fmtPct(line.pct, { fine: range === 'day', signs: colouredSigns() }))}`; chart?.destroy(); chart = null; @@ -94,7 +111,7 @@ export async function renderReturnWidget(host, instance) { } export async function renderReturnSettings(host, instance, commit) { - const assets = (await listAssets()).sort(byKindAndLabel); + const assets = (await listBookableAssets()).sort(byKindAndLabel); const current = dataOf(instance); const opt = (value, label) => ``; const kinds = ENUMS.ASSET_KIND.filter(k => assets.some(a => a.kind === k)); diff --git a/package-lock.json b/package-lock.json index 6d29bca..7cb63a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "assetapp", - "version": "0.3.2", + "version": "0.3.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "assetapp", - "version": "0.3.2", + "version": "0.3.3", "dependencies": { "@noble/curves": "2.4.0" }, diff --git a/package.json b/package.json index 12ecc70..baa3b0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "assetapp", - "version": "0.3.2", + "version": "0.3.3", "private": true, "type": "module", "scripts": { diff --git a/server/data/_limits.js b/server/data/_limits.js index f85198a..f1f7442 100644 --- a/server/data/_limits.js +++ b/server/data/_limits.js @@ -1,7 +1,6 @@ -// Generated, do not edit. sha256:37f1d463b03d2b5d702238cb632740786fc53e2072e4691719327d700c59d56c +// Generated, do not edit. sha256:fd977989705c07dc15f67feef3edd971f7d3fa3c94e064e7618ee1e171f4ce7e import { capacityReached } from '../license.mjs'; import * as db from '../db.js'; -import { counts } from './counts.js'; import { RATE_ONLY_ASSET } from './_shared.js'; import { getBaseCurrency } from './portfolio.js'; @@ -15,9 +14,7 @@ function assetCount() { } export function currentCount(soort) { - const c = counts(); if (soort === 'assets') return assetCount(); - if (soort === 'valuations') return c.valuations; if (soort === 'fiatAccounts') return fiatAccountCount(); throw new Error(`No counter for capacity '${soort}' yet.`); } diff --git a/server/data/accounts-merge.js b/server/data/accounts-merge.js index 7262045..3446289 100644 --- a/server/data/accounts-merge.js +++ b/server/data/accounts-merge.js @@ -1,7 +1,8 @@ -// Generated, do not edit. sha256:ebad02dba29ae50bcbaf9c21bb59936cf43f6be868e86ac00d0e6055f404b26f +// Generated, do not edit. sha256:36119ec87b42a3428d74ef9e16a174eb6f028b536ffdcea60da0bd3e970bac77 import * as db from '../db.js'; import { ACCOUNT_SOURCE_KINDS } from '../../shared/config.js'; import { fail } from '../../shared/app-error.js'; +import { hasFeature } from '../license.mjs'; import { eventsNetByAccount } from './events.js'; import { trackUpdate, trackUpdateWhere, trackDelete, trackDeleteWhere, withOrigin } from './change-log.js'; @@ -34,6 +35,7 @@ export function mergeCheck(survivorId, victimId) { } export async function mergeAccounts(survivorId, victimId) { + if (!hasFeature('accountMerge')) fail('accounts.mergePaid', null, 'Merging accounts belongs to the full edition.'); survivorId = Number(survivorId); victimId = Number(victimId); const chk = mergeCheck(survivorId, victimId); if (!chk.ok) fail(`accounts.mergeReason_${chk.reason}`, null, `Merge not possible (${chk.reason}).`); diff --git a/server/data/dashboard.js b/server/data/dashboard.js index f8428ef..730427c 100644 --- a/server/data/dashboard.js +++ b/server/data/dashboard.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:ebca807e87ebabedc0e0ca214ca3bec781ace05d2be4dc4ed8d664c767fe1d63 +// Generated, do not edit. sha256:1cab6c030597184175a0db5bb668aea9074d983a3f04b5255055f6a7df3c07d8 import * as db from '../db.js'; import { DASHBOARD } from '../../shared/config.js'; import { toSearchName } from '../../shared/search-name.js'; @@ -84,16 +84,20 @@ function assertWidgetType(type) { } } -export async function addWidget(profileId, { instanceKey, type, gridX = 0, gridY = 0, assetId = null, settings = null }) { +export async function addWidget(profileId, { instanceKey, type, gridX = 0, gridY = 0, assetId = null, settings = null, spanWidth = null }) { if (!db.one(`SELECT id FROM DashboardProfile WHERE id = ?`, [profileId])) { fail('dashboard.unknownProfile', { id: profileId }, `Dashboard profile #${profileId} does not exist.`); } assertWidgetType(type); + const span = spanWidth ?? DASHBOARD.WIDGETS[type].defaultSpan; + if (!Number.isInteger(span) || span < 1 || span > DASHBOARD.GRID_COLUMNS) { + throw new Error(`Widget width ${spanWidth} is not 1 to ${DASHBOARD.GRID_COLUMNS} columns.`); + } const key = instanceKey || type; if (db.one(`SELECT 1 AS x FROM DashboardWidget WHERE profileId = ? AND instanceKey = ?`, [profileId, key])) return false; const json = settings && typeof settings === 'object' && Object.keys(settings).length ? JSON.stringify(settings) : null; db.run(`INSERT INTO DashboardWidget (profileId, assetId, instanceKey, gridX, gridY, spanWidth, spanHeight, type, settings) - VALUES (?,?,?,?,?,?,NULL,?,?)`, [profileId, assetId, key, gridX, gridY, DASHBOARD.WIDGETS[type].defaultSpan, type, json]); + VALUES (?,?,?,?,?,?,NULL,?,?)`, [profileId, assetId, key, gridX, gridY, span, type, json]); await db.persist(); return true; } diff --git a/server/data/onboarding.js b/server/data/onboarding.js index 7e4fac4..5f9906e 100644 --- a/server/data/onboarding.js +++ b/server/data/onboarding.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:329990ff910102e84cb67048624a913db4948fa6ef673de3eb40c65c633864ba +// Generated, do not edit. sha256:bf3b89b4669e19b78df9f4741f695e6025ab616c2c0a5f205b84e84c1ce21f92 import * as db from '../db.js'; import { ASSET_DEFINITIONS, DASHBOARD } from '../../shared/config.js'; import { toSearchName } from '../../shared/search-name.js'; @@ -38,6 +38,8 @@ async function ensureAccount({ name, kind }) { return createAccount({ name, kind, isOwnCustody: own, scanEnabled: false, taxCategory: null }); } +const SETUP_SPAN = 4; + function placeInFreeSpace(rows, items) { const cols = DASHBOARD.GRID_COLUMNS; const heightOf = (type, h) => (h > 0 ? h : DASHBOARD.WIDGETS[type]?.defaultH || 1); @@ -47,7 +49,7 @@ function placeInFreeSpace(rows, items) { for (let c = r.gridX; c < Math.min(cols, r.gridX + r.spanWidth); c++) bottom[c] = Math.max(bottom[c], end); } return items.map(({ prefer, ...w }) => { - const span = DASHBOARD.WIDGETS[w.type].defaultSpan; + const span = w.spanWidth ?? DASHBOARD.WIDGETS[w.type].defaultSpan; let bestX = 0, bestY = Infinity; for (let x = 0; x + span <= cols; x++) { const y = Math.max(...bottom.slice(x, x + span)); @@ -74,7 +76,7 @@ export async function completeSetup({ assets = [], persona = 'broad', accounts = const add = []; if (widgets.includes('standing')) add.push({ type: 'standing', prefer: 4 }); if (widgets.includes('signal') && persona === 'bitcoin') add.push({ type: 'signal', prefer: 4 }); - if (widgets.includes('spot')) assetIds.forEach(id => add.push({ type: 'spot', instanceKey: `spot-${id}`, assetId: id, prefer: 0, settings: { momentum: false } })); + if (widgets.includes('spot')) assetIds.forEach(id => add.push({ type: 'spot', instanceKey: `spot-${id}`, assetId: id, prefer: 0, settings: { momentum: false }, spanWidth: SETUP_SPAN })); let widgetCount = 0; for (const w of placeInFreeSpace(listWidgets(profileId), add)) if (await addWidget(profileId, w)) widgetCount++; diff --git a/server/data/valuations.js b/server/data/valuations.js index aabc60b..fa2111b 100644 --- a/server/data/valuations.js +++ b/server/data/valuations.js @@ -1,9 +1,8 @@ -// Generated, do not edit. sha256:297c7a1d9ed86e15053cd37bb7126f5fb5b54d94b67e8da901fb66f370ca9301 +// Generated, do not edit. sha256:bd828bb299e2fd6141c6257cc9c20d5c7b2b7cc88932040bd9b98ce4dfeddd09 import * as db from '../db.js'; import { ENUMS } from '../../shared/config.js'; import { nowUtcIso } from '../../shared/time.js'; import { assertEnum } from './_shared.js'; -import { capacityReachedFor } from './_limits.js'; import { fail } from '../../shared/app-error.js'; import { eventsCountByAccount, eventsNetByAccount } from './events.js'; import { trackDelete, trackUpdate } from './change-log.js'; @@ -123,11 +122,6 @@ export async function deleteValuation(id) { } export async function createValuation(v) { assertEnum('source', ENUMS.VALUATION_SOURCE, v.source); - const max = capacityReachedFor('valuations'); - if (max !== null) { - fail('valuations.maxFree', { max }, - `The free version holds ${max} balance(s). A licence lifts that; nothing is removed in the meantime.`); - } db.run(`INSERT INTO Valuation (assetId, valuedOn, accountId, balance, fiatRate, rateAt, source) VALUES (?,?,?,?,?,?,?)`, [v.assetId, v.valuedOn, v.accountId ?? null, v.balance, v.fiatRate, v.rateAt, v.source]); diff --git a/server/db/conn.mjs b/server/db/conn.mjs index b1cf1c7..ed2b761 100644 --- a/server/db/conn.mjs +++ b/server/db/conn.mjs @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:95f28c26a77b79beac5f8c6818bd25243362641c1d8549949427a847e4f810f9 +// Generated, do not edit. sha256:232164f95c0eb5137f0c20ab218bdb9ffd81d26142889e12d2caf11dfbc181a3 import { DatabaseSync } from 'node:sqlite'; export const BUSY_TIMEOUT_MS = 5000; @@ -30,6 +30,16 @@ export function withOtherDatabase(pad, fn) { } } +export function peekDatabase(pad, fn) { + const peek = new DatabaseSync(pad, { readOnly: true }); + const all = (sql, params = []) => peek.prepare(sql).all(...bind(params)).map(rij => ({ ...rij })); + try { + return fn({ all, one: (sql, params = []) => all(sql, params)[0] ?? null }); + } finally { + peek.close(); + } +} + export function closeDatabase() { if (!db) return; db.close(); diff --git a/server/db/seeds.js b/server/db/seeds.js index 5333933..caa11df 100644 --- a/server/db/seeds.js +++ b/server/db/seeds.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:52135637bc4779b2b5f755ec50fedf41d2fa7b65d90a35f911c4e68f0b093874 +// Generated, do not edit. sha256:9946c137bb48925908ab17af61fbcdfb543a87d4be25e34812a95d4084af9425 import { CONFIG, PREFERENCES, SOURCE_CAPABILITIES, SOURCE_ENDPOINTS, DASHBOARD } from '../../shared/config.js'; import { toSearchName } from '../../shared/search-name.js'; import { run, one, all, lastId } from './conn.mjs'; @@ -176,7 +176,10 @@ export function seedDashboardProfile() { return true; } -const FRESH_VALUES = Object.freeze({ app: Object.freeze({ market_spot: 'first' }) }); +const FRESH_VALUES = Object.freeze({ + app: Object.freeze({ market_spot: 'first' }), + ai: Object.freeze({ enabled: 0 }), +}); export function seedPreferences() { for (const [scope, keys] of Object.entries(PREFERENCES)) { diff --git a/server/demo.mjs b/server/demo.mjs new file mode 100644 index 0000000..933c957 --- /dev/null +++ b/server/demo.mjs @@ -0,0 +1,131 @@ +// Generated, do not edit. sha256:c7cd149bf7a3cd10c21ce3f8a14833aa6c606b7953811447bfbf09af17e22088 +import { mkdirSync } from 'node:fs'; +import { join } from 'node:path'; + +import { CONFIG } from '../shared/config.js'; +import { priceFromTotal } from '../shared/units.js'; +import { toSearchName } from '../shared/search-name.js'; +import { initDatabase, closeDatabase, one } from './db.js'; +import { portfolioDir, listPortfolios } from './portfolios.mjs'; +import { hasFeature } from './license.mjs'; +import { completeSetup } from './data/onboarding.js'; +import { createEvent } from './data/events.js'; +import { createValuation } from './data/valuations.js'; + +export const DEMO_MONTHS = 30; + +const BTC_EUR = { + '2023-01': 21000, '2023-04': 27000, '2023-07': 26500, '2023-10': 32000, + '2024-01': 39000, '2024-02': 48000, '2024-03': 63000, '2024-04': 59000, '2024-05': 62000, '2024-06': 58000, + '2024-07': 59000, '2024-08': 54000, '2024-09': 57000, '2024-10': 63000, '2024-11': 88000, '2024-12': 92000, + '2025-01': 97000, '2025-02': 84000, '2025-03': 78000, '2025-04': 82000, '2025-05': 92000, '2025-06': 91000, + '2025-07': 100000, '2025-08': 97000, '2025-09': 96000, '2025-10': 98000, '2025-11': 82000, '2025-12': 76000, + '2026-01': 79000, '2026-02': 74000, '2026-03': 72000, '2026-04': 78000, '2026-05': 84000, '2026-06': 88000, + '2026-07': 92000, '2026-08': 90000, '2026-09': 94000, '2026-10': 96000, +}; +const MONTHS = Object.keys(BTC_EUR).sort(); + +const SAT = 1e8; +const CENT = 100; +const ACCOUNTS = Object.freeze({ + exchange: { name: 'Exchange', kind: 'exchange' }, + wallet: { name: 'Hardware wallet', kind: 'wallet' }, + bank: { name: 'Bank', kind: 'bank' }, +}); + +const iso = (y, m, day) => new Date(Date.UTC(y, m, day, 10, 0, 0)).toISOString(); + +function priceOn(at) { + const key = at.slice(0, 7); + const idx = MONTHS.findIndex(k => k >= key); + const here = BTC_EUR[MONTHS[idx < 0 ? MONTHS.length - 1 : idx]]; + const next = BTC_EUR[MONTHS[Math.min((idx < 0 ? MONTHS.length - 1 : idx) + 1, MONTHS.length - 1)]]; + const frac = (Number(at.slice(8, 10)) - 1) / 30; + return Math.round(here + (next - here) * frac); +} + +export function demoRows(today = new Date()) { + const rows = []; + const pos = { exchange: 0, wallet: 0, bank: 0 }; + const nu = today.toISOString(); + const start = new Date(Date.UTC(today.getUTCFullYear(), today.getUTCMonth() - (DEMO_MONTHS - 1), 1)); + const add = (r) => { if (r.at <= nu) rows.push(r); return r.at <= nu; }; + + for (let i = 0; i < DEMO_MONTHS; i++) { + const y = start.getUTCFullYear(), m = start.getUTCMonth() + i; + if (i === 0 && add({ kind: 'event', type: 'buy', asset: 'EUR', to: 'bank', at: iso(y, m, 1), amount: 4000 * CENT, fiatPrice: 1 })) pos.bank += 4000 * CENT; + if (add({ kind: 'event', type: 'buy', asset: 'EUR', to: 'bank', at: iso(y, m, 1), amount: 900 * CENT, fiatPrice: 1 })) pos.bank += 900 * CENT; + for (const day of [2, 9, 16, 23]) { + const at = iso(y, m, day); + const price = priceOn(at); + const fee = 0.4; + const amount = Math.round((75 - fee) / price * SAT); + if (add({ kind: 'event', type: 'buy', asset: 'BTC', to: 'exchange', at, amount, fiatPrice: priceFromTotal(75, amount, 8, fee, 'buy'), fiatFee: fee })) { + pos.exchange += amount; + } + } + if (i % 4 === 3) { + const amount = pos.exchange - 100_000; + if (amount > 0 && add({ kind: 'event', type: 'transfer', asset: 'BTC', from: 'exchange', to: 'wallet', at: iso(y, m, 26), amount })) { + pos.exchange -= amount; pos.wallet += amount; + } + } + if (i === 20) { + const amount = 2_000_000; + if (add({ kind: 'event', type: 'transfer', asset: 'BTC', from: 'wallet', to: 'exchange', at: iso(y, m, 10), amount })) { + pos.wallet -= amount; pos.exchange += amount; + const at = iso(y, m, 11); + if (add({ kind: 'event', type: 'sell', asset: 'BTC', from: 'exchange', at, amount, fiatPrice: priceOn(at), fiatFee: 2 })) pos.exchange -= amount; + } + } + if (m % 3 === 2) { + const amount = Math.round(pos.bank * 0.015 / 4); + if (amount > 0 && add({ kind: 'event', type: 'interest', asset: 'EUR', to: 'bank', at: iso(y, m, 28), amount, fiatPrice: 1 })) pos.bank += amount; + } + const peil = (account, asset) => { + const at = new Date(Date.UTC(y, m, 28, 22, 0, 0)).toISOString(); + add({ kind: 'valuation', asset, account, at, valuedOn: at.slice(0, 10), balance: pos[account], + fiatRate: asset === 'EUR' ? 1 : priceOn(at) }); + }; + if (m % 6 === 5) { peil('bank', 'EUR'); if (pos.wallet > 0) peil('wallet', 'BTC'); } + if (m % 12 === 11 && pos.exchange > 0) peil('exchange', 'BTC'); + } + return rows; +} + +export async function seedDemo(today = new Date()) { + const accounts = Object.values(ACCOUNTS); + await completeSetup({ assets: ['BTC'], persona: 'broad', accounts, widgets: ['standing', 'spot'] }); + const assetId = (symbol) => one(`SELECT id FROM Asset WHERE symbol = ?`, [symbol]).id; + const accountId = (key) => one(`SELECT id FROM Account WHERE searchName = ?`, [toSearchName(ACCOUNTS[key].name)]).id; + const ids = { BTC: assetId('BTC'), EUR: assetId('EUR') }; + for (const r of demoRows(today)) { + if (r.kind === 'event') { + await createEvent({ + assetId: ids[r.asset], type: r.type, occurredAt: r.at, amount: r.amount, fiatPrice: r.fiatPrice ?? null, + fiatFee: r.fiatFee ?? null, fromAccountId: r.from ? accountId(r.from) : null, + toAccountId: r.to ? accountId(r.to) : null, source: 'manual', + }); + } else { + await createValuation({ assetId: ids[r.asset], accountId: accountId(r.account), balance: r.balance, + fiatRate: r.fiatRate, valuedOn: r.valuedOn, rateAt: r.at, source: 'manual' }); + } + } +} + +export async function createDemoPortfolio(today = new Date()) { + const map = portfolioDir(CONFIG.PORTFOLIO.DEMO_NAME); + mkdirSync(map, { recursive: true }); + initDatabase(join(map, 'db.sqlite')); + try { + await seedDemo(today); + } finally { + closeDatabase(); + } +} + +export async function ensureDemo(layout) { + if (!layout.fresh || hasFeature('portfolios') || listPortfolios().some(p => p.demo)) return false; + await createDemoPortfolio(); + return true; +} diff --git a/server/index.mjs b/server/index.mjs index 124a32e..fd66790 100644 --- a/server/index.mjs +++ b/server/index.mjs @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:b9a3a6b8f1e1fdbee54a4d9e67411a1659c1ea24437a706bbf1a46f443c3b26d +// Generated, do not edit. sha256:a2dbaa6a0b5bd22d02f0f5bce9b00466d953e01821cc546e4e9315325da7765a import { createServer as createHttpServer } from 'node:http'; import { createServer as createHttpsServer } from 'node:https'; import { spawn } from 'node:child_process'; @@ -8,6 +8,8 @@ import { initDatabase, one } from './db.js'; import { getProvider } from './data/providers.js'; import { moveProviderKeys } from './keys.mjs'; import { prepareLayout } from './portfolios.mjs'; +import { ensureDemo } from './demo.mjs'; +import { CONFIG } from '../shared/config.js'; import { licenseState, appVersion, hasFeature } from './license.mjs'; import { getPref } from './data/preferences.js'; import { adoptInstallLocale } from './installation.mjs'; @@ -29,7 +31,13 @@ function openInBrowser(url) { let credentials, tls, binding, dbRegel, portefeuilleRegel; try { - portefeuilleRegel = prepareLayout().regel; + const layout = prepareLayout(); + portefeuilleRegel = layout.regel; + try { + if (await ensureDemo(layout)) portefeuilleRegel += ` | demo: ${CONFIG.PORTFOLIO.DEMO_NAME} aangemaakt`; + } catch (e) { + console.error(`[assetapp] demo niet aangemaakt: ${e.message}`); + } credentials = await loadCredentials(); tls = await loadTlsOptions(); binding = resolveBinding({ tls: Boolean(tls), credentials, host: process.env.ASSETAPP_HOST || null }); diff --git a/server/portfolios-admin.mjs b/server/portfolios-admin.mjs index 018b239..360fd70 100644 --- a/server/portfolios-admin.mjs +++ b/server/portfolios-admin.mjs @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:1c5123afde8b42e8b0c7944a90a9a3952b38ed44748eb715f09bb8aa35f593d5 +// Generated, do not edit. sha256:a56d0789a1d23362a10302d4a28be7384372f8aa39766c83b8df92fa4456f11e import { mkdir, readdir, rename, rm, readFile, writeFile, copyFile, stat } from 'node:fs/promises'; import { join, sep, resolve } from 'node:path'; @@ -6,7 +6,7 @@ import { installDir, portfolioDir, archiveDir, assertValidName, sameName, activeName, writeActiveName, listPortfolios, } from './portfolios.mjs'; -import { run } from './db/conn.mjs'; +import { run, peekDatabase } from './db/conn.mjs'; import { createDatabase } from './db.js'; import { CONFIG } from '../shared/config.js'; import { fail } from '../shared/app-error.js'; @@ -45,7 +45,7 @@ export async function createPortfolio(naam, { kopieVan = null, baseCurrency = nu if (kopieVan && baseCurrency) { throw new Error('A copy keeps the unit of account of its source; do not pass baseCurrency with kopieVan.'); } - const max = capacityReached('portfolios', listPortfolios().length); + const max = capacityReached('portfolios', listPortfolios().filter(p => !p.demo).length); if (max !== null) { fail('portfolios.maxFree', { max }, `The free version holds ${max} portfolio(s). A licence lifts that; nothing is removed in the meantime.`); @@ -155,11 +155,40 @@ export async function purgeArchived(naam) { return { naam, map }; } +function keyFigures(naam) { + const pad = join(portfolioDir(naam), 'db.sqlite'); + const perSoort = rijen => Object.fromEntries(rijen.map(r => [r.kind, r.n])); + try { + return peekDatabase(pad, ({ one, all }) => { + const backup = one(`SELECT value FROM Preference WHERE scope = 'app' AND key = 'last_backup_at'`); + const eerste = [ + one(`SELECT MIN(occurredAt) AS d FROM Event WHERE type <> 'reservation'`).d, + one(`SELECT MIN(rateAt) AS d FROM Valuation WHERE accountId IS NOT NULL`).d, + ].filter(Boolean).sort()[0] || null; + const portfolio = one(`SELECT baseCurrency, createdAt FROM Portfolio WHERE id = 1`); + return { + munt: portfolio?.baseCurrency ?? null, + aangemaakt: portfolio?.createdAt ?? null, + boekingen: one(`SELECT COUNT(*) AS n FROM Event WHERE type <> 'reservation'`).n, + balansen: one(`SELECT COUNT(*) AS n FROM Valuation`).n, + assets: perSoort(all(`SELECT kind, COUNT(*) AS n FROM Asset WHERE id IN ( + SELECT assetId FROM Event WHERE type <> 'reservation' UNION SELECT assetId FROM Valuation) + GROUP BY kind`)), + accounts: perSoort(all(`SELECT kind, COUNT(*) AS n FROM Account WHERE isActive = 1 GROUP BY kind`)), + eersteJaar: eerste ? Number(eerste.slice(0, 4)) : null, + laatsteBackup: (backup && JSON.parse(backup.value)) || null, + }; + }); + } catch { + return null; + } +} + export async function overviewPortfolios() { return { actief: activeName(), installatie: installDir(), - portefeuilles: listPortfolios(), + portefeuilles: listPortfolios().map(p => ({ ...p, kerncijfers: p.heeftDatabase ? keyFigures(p.naam) : null })), archief: await listArchived(), }; } diff --git a/server/portfolios.mjs b/server/portfolios.mjs index ca86628..60b5fa1 100644 --- a/server/portfolios.mjs +++ b/server/portfolios.mjs @@ -1,8 +1,9 @@ -// Generated, do not edit. sha256:82917722010d150a76bf3e84051a5132d98df9cd1713d95fe6238971925d39e8 +// Generated, do not edit. sha256:ac3a8e4322658b62e93903e91a12ebe573e29b3520917e4d09d4d77210b67abb import { mkdirSync, readFileSync, writeFileSync, readdirSync, renameSync, statSync, rmSync } from 'node:fs'; import { join, resolve, dirname, sep } from 'node:path'; import { fileURLToPath } from 'node:url'; import { fail } from '../shared/app-error.js'; +import { CONFIG } from '../shared/config.js'; const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..'); @@ -124,6 +125,7 @@ export function listPortfolios() { return { naam, actief: actief !== null && sameName(naam, actief), + demo: sameName(naam, CONFIG.PORTFOLIO.DEMO_NAME), heeftDatabase: bestaat(db), heeftGeheimen: bestaat(join(map, 'secrets.json')), laatstGebruikt: mtimeOf(db), @@ -194,6 +196,7 @@ export function prepareLayout() { hernoemOudeWijzer(); const migrated = migrateLooseLayout(); let naam = readActiveName(); + const fresh = !naam && !migrated && listPortfolios().length === 0; let herkomst = `uit ${POINTER_NAME}`; if (!naam) { naam = writeActiveName(migrated || DEFAULT_NAME); @@ -202,5 +205,5 @@ export function prepareLayout() { herkomst = `uit ${POINTER_NAME}; losse bestanden verhuisd naar '${migrated}'`; } mkdirSync(portfolioDir(naam), { recursive: true }); - return { name: naam, migrated, regel: `portefeuille: ${naam} (${herkomst}) | map: ${portfolioDir(naam)}` }; + return { name: naam, migrated, fresh, regel: `portefeuille: ${naam} (${herkomst}) | map: ${portfolioDir(naam)}` }; } diff --git a/shared/config.js b/shared/config.js index fc67939..c8ab815 100644 --- a/shared/config.js +++ b/shared/config.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:79db5d8cc5706ad987b207d98e1c67ca389284a24121f65b199acbe48bce76ec +// Generated, do not edit. sha256:1710b5a1008b7f73cde7525daaf3570e3ed0738fc95514486b369ae15598fb4b const GRAMS_PER_TROY_OUNCE = 31.1034768; export const CONFIG = Object.freeze({ @@ -243,9 +243,10 @@ export const CONFIG = Object.freeze({ { id: 'dashboard', group: 'overview', free: null }, { id: 'wealth', group: 'overview', free: null }, { id: 'returns', group: 'overview', free: null }, { id: 'taxes', group: 'overview', has: 'tax' }, { id: 'balances', group: 'records', free: null }, { id: 'interest', group: 'records', free: null }, + { id: 'accountMerge', group: 'records', has: 'accountMerge' }, { id: 'import', group: 'records', has: 'import' }, { id: 'data', group: 'records', has: 'data' }, { id: 'health', group: 'records', has: 'health' }, { id: 'metals', group: 'records', free: false }, - { id: 'priceHistory', group: 'prices', free: null }, + { id: 'priceHistory', group: 'prices', has: 'priceHistory' }, { id: 'sourceChoice', group: 'prices', has: 'sourceMatrix' }, { id: 'providerKeys', group: 'prices', has: 'providerKeys' }, { id: 'portfolios', group: 'app', has: 'portfolios' }, { id: 'ai', group: 'app', has: 'ai' }, { id: 'kiosk', group: 'app', has: 'kiosk' }, @@ -266,7 +267,6 @@ export const CONFIG = Object.freeze({ assets: 1, fiatAccounts: 1, portfolios: 1, - valuations: 1, }), ASSETS: Object.freeze(['BTC']), HAS: Object.freeze({ @@ -283,6 +283,8 @@ export const CONFIG = Object.freeze({ data: false, health: false, kiosk: false, + accountMerge: false, + priceHistory: false, }), }), }), @@ -300,6 +302,7 @@ export const CONFIG = Object.freeze({ PORTFOLIO: Object.freeze({ RESTART_EXIT_CODE: 75, + DEMO_NAME: 'Demo', DEFAULT_BASE_CURRENCY: 'EUR', BASE_CURRENCIES: Object.freeze([ 'AUD', 'BRL', 'CAD', 'CHF', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'ISK', diff --git a/shared/i18n/en.js b/shared/i18n/en.js index f84a850..d2dc0b2 100644 --- a/shared/i18n/en.js +++ b/shared/i18n/en.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:e2490264df449b0893dfa0c9153c9a28823fc105b7143f0c7281166235765818 +// Generated, do not edit. sha256:33299173b137f702925900408d288146bebcc5895b1c84a7d6e2f52c4663aa64 export const en = { places: { HOME: 'The dashboard. You build the layout yourself from widgets (add, drag, adjust width, restore the default layout) and see balances, prices and signals at a glance.', @@ -383,7 +383,7 @@ export const en = { license: { title: 'Free and full version', body: [ - 'The free version has no time limit, with small records: one asset, one fiat account, one balance and one portfolio.', + 'The free version has no time limit, with small records: one asset, one fiat account and one portfolio.', 'Integrations, the source choice, your own API keys and the tax page are part of the full version. Reading and exporting always keep working; nothing is ever taken away.', 'The license file goes on {LICENSE} and takes effect immediately. Every lock elsewhere in the app points here.', ], diff --git a/shared/i18n/nl.js b/shared/i18n/nl.js index 4bfa49d..b2f553b 100644 --- a/shared/i18n/nl.js +++ b/shared/i18n/nl.js @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:88c3787099bdacec2cc7f0323d565d172c1d53d814c3d3c14973885706e0e046 +// Generated, do not edit. sha256:1da9478920ae7b61142019f1be56d25f8f2f2cbc26eb597cd15c9947103fe78a export const nl = { places: { HOME: 'Het dashboard. U stelt de indeling zelf samen uit widgets (toevoegen, verslepen, breedte aanpassen, standaardindeling herstellen) en ziet in één oogopslag saldi, koersen en signalen.', @@ -22,11 +22,11 @@ export const nl = { RESERVATIONS: 'Reserveringen. U legt per account een bedrag vast dat later mogelijk wordt afgeschreven of bijgeboekt; het telt nergens mee tot u het boekt of zonder boeking afhandelt.', ACCOUNTS: 'Accounts. U maakt een account aan, sluit het af of heropent het, zet automatisch scannen aan, en koppelt er wallet-bronnen aan (een xpub of los adres). Ook samenvoegen kan hier.', ASSETS: 'Assets. U voegt een asset toe of wijzigt hem (symbool, eenheid, ondereenheid, precisie, weergave), en beheert de metaalproducten die eronder hangen.', - PORTFOLIOS: 'Portefeuilles. Elke portefeuille is een eigen administratie, met een eigen database en eigen geheimen; er is er altijd precies één open. U maakt er een aan (leeg of als kopie van een bestaande), schakelt over naar een andere (de app start daarvoor opnieuw), hernoemt of verwijdert er een, en stelt in wie er bij deze portefeuille mag. Verwijderen verplaatst naar het archief; daar kan het definitief weg. Hier staan ook de handelingen op de administratie als bestand: een back-up maken, de database exporteren of terugzetten, en leeg beginnen.', + PORTFOLIOS: 'Portfolio\'s. Elk portfolio is een eigen administratie, met een eigen database en eigen geheimen; er is er altijd precies één open. U maakt er een aan (leeg of als kopie van een bestaand), schakelt over naar een ander (de app start daarvoor opnieuw), hernoemt of verwijdert er een, en stelt in wie er bij dit portfolio mag. Verwijderen verplaatst naar het archief; daar kan het definitief weg. Hier staan ook de handelingen op de administratie als bestand: een back-up maken, de database exporteren of terugzetten, en leeg beginnen.', SETTINGS: 'Instellingen. Thema en accentkleur, valuta, taal, de privacy-blur, welke naam een asset in tabellen krijgt, en de intervallen van de achtergrondtaken.', LICENSE: 'Licentie. Welke versie deze installatie draait, voor wie de licentie is en voor welke hoofdversies, en waar u een licentiebestand neerzet. Elk slot elders in de app verwijst hierheen.', IMPORT: 'Importeren. U leest gebeurtenissen in uit een CSV-bestand, koppelt de kolommen aan de velden en ziet vóór het opslaan wat er zou worden toegevoegd.', - DATA: 'Data. Een read-only kijkje in de rauwe inhoud van de tabellen. Bedoeld om te controleren, niet om te wijzigen; de back-up staat bij Portefeuilles.', + DATA: 'Data. Een read-only kijkje in de rauwe inhoud van de tabellen. Bedoeld om te controleren, niet om te wijzigen; de back-up staat bij Portfolio\'s.', HEALTH: 'Gezondheid. Tien controles op de administratie zelf, met per bevinding wat er aan de hand is: dubbele boekingen, balansen die niet verzoend zijn, achterstand en gaten in de koershistorie, verplaatsingen zonder tegenkant. U leest hier, u handelt af op Af te handelen.', AI_ACTIVITY: 'AI-activiteit. U zet de AI-koppeling en het navigatierecht aan of uit, leest per aanroep na wat er gebeurde en welke velden de app verlieten, en bekijkt vooraf wat een handeling zou delen.', INTEGRATIONS: 'Integraties. Het beheer van alles wat buiten de app zit: koersbronnen, hun sleutels, de verbindingen met een explorer of node, en voorstellen voor nieuwe bronnen.', @@ -275,9 +275,9 @@ export const nl = { ['Navigatie', 'Het scherm naar een andere pagina brengen, na een aftelling met een stopknop.'], ['Onbewerkt delen', 'Uit ziet de AI verwijzingen en marges in plaats van namen en bedragen.'], ] }, - { note: 'Onbewerkt delen alleen aanzetten in een portefeuille zonder echte gegevens.' }, + { note: 'Onbewerkt delen alleen aanzetten in een portfolio zonder echte gegevens.' }, 'Daaronder bepalen vier schuiven hoe precies de AI de cijfers ziet: percentages, totalen, bedragen en hoeveelheden, als marge of exact.', - 'Elke aanroep staat op {AI_ACTIVITY}, met de gegevens die daarbij de app verlieten. De instellingen gelden per portefeuille en meteen, zonder herstart.', + 'Elke aanroep staat op {AI_ACTIVITY}, met de gegevens die daarbij de app verlieten. De instellingen gelden per portfolio en meteen, zonder herstart.', ], }, interest: { @@ -383,19 +383,19 @@ export const nl = { license: { title: 'Gratis en volledige versie', body: [ - 'De gratis versie is onbeperkt in tijd, met een kleine administratie: één asset, één fiatrekening, één balans en één portefeuille.', + 'De gratis versie is onbeperkt in tijd, met een kleine administratie: één asset, één fiatrekening en één portfolio.', 'Koppelingen, de bronkeuze, eigen sleutels en de belastingpagina horen bij de volledige versie. Lezen en exporteren blijven altijd werken; er wordt nooit iets weggehaald.', 'Het licentiebestand gaat op {LICENSE} en geldt meteen. Elk slot elders in de app verwijst hierheen.', ], }, portfolios: { - title: 'Portefeuilles', + title: "Portfolio's", body: [ - 'Elke portefeuille is een aparte administratie, met een eigen database en eigen geheimen. Er is er altijd één open.', + 'Elk portfolio is een aparte administratie, met een eigen database en eigen geheimen. Er is er altijd één open.', { list: [ ['Rekenvaluta', 'Gekozen bij het aanmaken en daarna vast. Alle bedragen staan in die munt.'], ['Wisselen', 'De app start daarvoor opnieuw.'], - ['Verwijderen', 'Verplaatst de portefeuille naar het archief. Pas daar kan hij definitief weg.'], + ['Verwijderen', 'Verplaatst het portfolio naar het archief. Pas daar kan het definitief weg.'], ] }, { note: 'Een back-up bevat database en geheimen samen: alleen samen kloppen ze.' }, ], diff --git a/tests/db/seeds.test.mjs b/tests/db/seeds.test.mjs index 01a9c39..1f48b98 100644 --- a/tests/db/seeds.test.mjs +++ b/tests/db/seeds.test.mjs @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:3914f1ddc9004d83b8401e7c0b8dbbc55835029676e9b46f33978bfb59e5b5ee +// Generated, do not edit. sha256:b4e0276b7d4bc8c4728c77282dde12358131e2103dd3182aa9dbf27cc334764b import { describe, it, beforeEach, afterEach } from 'node:test'; import assert from 'node:assert/strict'; @@ -261,6 +261,12 @@ describe('seedPreferences', () => { assert.equal(PREFERENCES.app.market_spot.initial, 'off', 'de terugval van een bestaande portefeuille'); }); + it('zet de AI-koppeling uit in een verse database, en laat de terugval aan', () => { + seedPreferences(); + assert.equal(waarde('ai', 'enabled'), 0); + assert.equal(PREFERENCES.ai.enabled.initial, 1, 'de terugval van een bestaande portefeuille'); + }); + it('laat de andere voorkeuren op hun initial', () => { seedPreferences(); assert.equal(waarde('app', 'result_signs'), PREFERENCES.app.result_signs.initial); diff --git a/tests/price/btc-explorer-retry.test.mjs b/tests/price/btc-explorer-retry.test.mjs new file mode 100644 index 0000000..ac17bf6 --- /dev/null +++ b/tests/price/btc-explorer-retry.test.mjs @@ -0,0 +1,51 @@ +// Generated, do not edit. sha256:4bf1820de70357b7a7e29ccee6fc599f970ee70dfc5b2f00ce791c38d33bc92e +import { describe, it, mock, afterEach } from 'node:test'; +import assert from 'node:assert/strict'; + +const { fetchJson } = await import('../../client/price/btc-explorer.js'); + +const echteFetch = globalThis.fetch; +afterEach(() => { globalThis.fetch = echteFetch; mock.timers.reset(); }); + +async function uitzitten(belofte) { + let klaar = false; + const uit = belofte.then(v => ({ v }), e => ({ e })).finally(() => { klaar = true; }); + while (!klaar) { + await new Promise(r => setImmediate(r)); + mock.timers.runAll(); + } + return uit; +} + +const ok = body => ({ ok: true, status: 200, json: async () => body }); +const status = s => ({ ok: false, status: s, json: async () => ({}) }); + +describe('fetchJson: opnieuw proberen', () => { + it('zit drie netwerkfouten uit en geeft dan het antwoord', async () => { + mock.timers.enable({ apis: ['setTimeout'] }); + let n = 0; + globalThis.fetch = async () => { if (++n <= 3) throw new TypeError('Failed to fetch'); return ok({ x: 1 }); }; + const { v, e } = await uitzitten(fetchJson('https://x/api', 'X')); + assert.equal(e, undefined); + assert.deepEqual(v, { x: 1 }); + assert.equal(n, 4); + }); + + it('geeft na de vierde mislukte poging de fout van de laatste', async () => { + mock.timers.enable({ apis: ['setTimeout'] }); + let n = 0; + globalThis.fetch = async () => { n++; return status(429); }; + const { e } = await uitzitten(fetchJson('https://x/api', 'X')); + assert.ok(e); + assert.equal(n, 4); + }); + + it('probeert een 404 niet opnieuw', async () => { + mock.timers.enable({ apis: ['setTimeout'] }); + let n = 0; + globalThis.fetch = async () => { n++; return status(404); }; + const { e } = await uitzitten(fetchJson('https://x/api', 'X')); + assert.ok(e); + assert.equal(n, 1); + }); +}); diff --git a/tests/repo/license-limits.test.mjs b/tests/repo/license-limits.test.mjs index ed5f8b0..cce9b49 100644 --- a/tests/repo/license-limits.test.mjs +++ b/tests/repo/license-limits.test.mjs @@ -1,4 +1,4 @@ -// Generated, do not edit. sha256:38c4b07d1566cda74ef6cac4d031f49fd52004b6938fdee8f13e3e7678fc12c7 +// Generated, do not edit. sha256:13b6b32cbbf6b8c4a6a6069af37a7be33560a8abfc2af81ae2b4009e9692d7c6 import { describe, it, beforeEach, mock } from 'node:test'; import assert from 'node:assert/strict'; import { createDbHarness } from '../helpers/db-node.mjs'; @@ -22,6 +22,7 @@ mock.module('../../server/license.mjs', { const { createAsset, updateAsset, deleteAsset, listAssets } = await import('../../server/data/assets.js'); const { createAccount, listAccounts } = await import('../../server/data/accounts.js'); +const { mergeAccounts } = await import('../../server/data/accounts-merge.js'); const { createValuation, listValuations } = await import('../../server/data/valuations.js'); const { saveConnection, listConnections } = await import('../../server/data/connections.js'); const { setPriceSourceRank } = await import('../../server/data/price-source.js'); @@ -148,23 +149,10 @@ describe('de gratis stand op balansen', () => { rateAt: `${dag}T00:00:00Z`, source: 'manual', }); - it('laat ÉÉN balans toe en weigert de tweede', async () => { + it('kent geen grens: ook de gratis stand legt balans na balans vast', async () => { const asset = await createAsset(EEN); - await createValuation(balans(asset, '2026-01-01')); - await assert.rejects(() => createValuation(balans(asset, '2026-02-01')), (fout) => { - assert.equal(fout.key, 'valuations.maxFree'); - assert.equal(fout.params.max, 1); - return true; - }); - assert.equal(listValuations().length, 1); - }); - - it('laat de tweede WEL toe in de betaalde stand', async () => { - const asset = await createAsset(EEN); - await createValuation(balans(asset, '2026-01-01')); - stand = { level: 'full', enforced: true, why: 'licensed' }; - await createValuation(balans(asset, '2026-02-01')); - assert.equal(listValuations().length, 2); + for (const dag of ['2026-01-01', '2026-02-01', '2026-03-01']) await createValuation(balans(asset, dag)); + assert.equal(listValuations().length, 3); }); }); @@ -212,4 +200,15 @@ describe('de features van de gratis stand', () => { await assert.rejects(() => setPriceSourceRank(asset, 'spot', 1), (f) => f.key === 'integrations.matrixPaid'); }); + + it('weigert accounts samenvoegen en laat beide accounts staan; betaald gaat het door', async () => { + const wallet = (name) => ({ name, kind: 'wallet', isOwnCustody: true, scanEnabled: false, taxCategory: null }); + const a = await createAccount(wallet('A')); + const b = await createAccount(wallet('B')); + await assert.rejects(() => mergeAccounts(a, b), (f) => f.key === 'accounts.mergePaid'); + assert.equal(listAccounts().length, 2); + stand = { level: 'full', enforced: true, why: 'licensed' }; + await mergeAccounts(a, b); + assert.deepEqual(listAccounts().map(r => r.id), [a]); + }); }); diff --git a/tests/repo/merge.test.mjs b/tests/repo/merge.test.mjs deleted file mode 100644 index 48fc3c3..0000000 --- a/tests/repo/merge.test.mjs +++ /dev/null @@ -1,302 +0,0 @@ -// Generated, do not edit. sha256:ba6482c6f8221f445c935cfd65e76c09e943da662ff5dab04e50d8a76e004316 -import { describe, it, beforeEach, mock } from 'node:test'; -import { toSearchName } from '../../shared/search-name.js'; -import assert from 'node:assert/strict'; - -import { createDbHarness } from '../helpers/db-node.mjs'; -import { ACCOUNT_SOURCE_KINDS } from '../../shared/config.js'; - -const harness = createDbHarness(); -mock.module('../../server/db.js', { namedExports: harness.exports }); - -const { mergeAccounts, mergeCheck } = await import('../../server/data/accounts-merge.js'); -const { eventsNetByAccount } = await import('../../server/data/events.js'); - -let btc; -beforeEach(() => { - harness.recreate(); - harness.exports.run( - `INSERT INTO Asset (symbol, name, searchName, kind, unit, subunit, decimals, displayUnit) VALUES ('BTC','Bitcoin','bitcoin','crypto','BTC','sat',8,'unit')`); - btc = harness.exports.lastId(); -}); - -function account(naam, kind = 'wallet') { - const eigen = ACCOUNT_SOURCE_KINDS[kind].length > 0 ? 1 : 0; - harness.exports.run( - `INSERT INTO Account (name, searchName, kind, isOwnCustody, scanEnabled, isActive, closedAt) VALUES (?,?,?,?,?,1,NULL)`, [naam, toSearchName(naam), kind, eigen, 0]); - return harness.exports.lastId(); -} -function event({ type = 'buy', from = null, to = null, amount = 1000, at = '2024-01-01T00:00:00', unitFee = null }) { - harness.exports.run( - `INSERT INTO Event (assetId, type, occurredAt, amount, fiatPrice, unitFee, fromAccountId, toAccountId, source, createdAt) - VALUES (?,?,?,?,?,?,?,?,'manual',?)`, - [btc, type, at, amount, type === 'buy' || type === 'sell' ? 1 : null, unitFee, from, to, at]); - return harness.exports.lastId(); -} -function waardering({ acc, onDate, balance, rateAt = null }) { - harness.exports.run( - `INSERT INTO Valuation (assetId, valuedOn, accountId, balance, fiatRate, rateAt, source) - VALUES (?,?,?,?,?,?, 'manual')`, - [btc, onDate, acc, balance, 50000, rateAt ?? `${onDate}T00:00:00`]); - return harness.exports.lastId(); -} -const tel = (tabel, kolom, id) => - harness.exports.one(`SELECT COUNT(*) AS n FROM ${tabel} WHERE ${kolom} = ?`, [id]).n; -const bestaatAccount = id => harness.exports.one(`SELECT 1 AS x FROM Account WHERE id=?`, [id]) != null; - -describe('mergeCheck: compatibiliteit', () => { - it('vraagt om twee accounts', () => { - const a = account('A'); - assert.equal(mergeCheck(a, null).reason, 'pickTwo'); - assert.equal(mergeCheck(null, a).reason, 'pickTwo'); - assert.equal(mergeCheck(a, null).counts, null); - }); - - it('weigert een account met zichzelf', () => { - const a = account('A'); - assert.equal(mergeCheck(a, a).reason, 'sameAccount'); - assert.equal(mergeCheck(String(a), a).reason, 'sameAccount', - 'ook als het id als string binnenkomt (uit een