|
26 | 26 | } from "../../wailsjs/go/main/App"; |
27 | 27 |
|
28 | 28 | interface Transaction { |
29 | | - id: number; |
| 29 | + id?: number; |
30 | 30 | type: "expense" | "revenue"; |
31 | 31 | desc: string; |
32 | 32 | cat: string; |
|
131 | 131 | let totalExp = $derived(expenses.reduce((s, r) => s + r.val, 0)); |
132 | 132 | let totalRev = $derived(revenues.reduce((s, r) => s + r.val, 0)); |
133 | 133 | let balance = $derived(totalRev - totalExp); |
134 | | - let last4 = $derived([...records].sort((a, b) => b.id - a.id).slice(0, 4)); |
| 134 | + let last4 = $derived([...records].sort((a, b) => (b.id ?? 0) - (a.id ?? 0)).slice(0, 4)); |
135 | 135 | let ledgerSorted = $derived( |
136 | 136 | [...filtered].sort( |
137 | | - (a, b) => b.date.localeCompare(a.date) || b.id - a.id, |
| 137 | + (a, b) => b.date.localeCompare(a.date) || (b.id ?? 0) - (a.id ?? 0), |
138 | 138 | ), |
139 | 139 | ); |
140 | 140 |
|
|
430 | 430 | // ── Backend calls ───────────────────────────────────────── |
431 | 431 | async function loadRecords() { |
432 | 432 | try { |
433 | | - records = await GetTransactions(dateFrom, dateTo); |
| 433 | + records = (await GetTransactions(dateFrom, dateTo)) as Transaction[]; |
434 | 434 | } catch (e) { |
435 | 435 | console.error("get_transactions failed:", e); |
436 | 436 | } |
|
474 | 474 | const date = isExp ? eDate : rDate; |
475 | 475 | const account_id = isExp |
476 | 476 | ? eAccountId === "" |
477 | | - ? null |
| 477 | + ? undefined |
478 | 478 | : eAccountId |
479 | 479 | : rAccountId === "" |
480 | | - ? null |
| 480 | + ? undefined |
481 | 481 | : rAccountId; |
482 | 482 | if (!desc || isNaN(val) || val <= 0 || !date || !cat) return; |
483 | 483 |
|
|
510 | 510 | const desc = eDesc.trim(); |
511 | 511 | const cat = eCat.trim(); |
512 | 512 | const n = parseInt(eInstallN); |
513 | | - const account_id = eAccountId === "" ? null : eAccountId; |
| 513 | + const account_id = eAccountId === "" ? undefined : eAccountId; |
514 | 514 | if ( |
515 | 515 | !desc || |
516 | 516 | isNaN(val) || |
|
565 | 565 | } |
566 | 566 |
|
567 | 567 | function startEdit(r: Transaction) { |
568 | | - editingId = r.id; |
| 568 | + editingId = r.id ?? null; |
569 | 569 | editType = r.type; |
570 | 570 | editVal = String(r.val); |
571 | 571 | editDesc = r.desc; |
|
597 | 597 | cat: editCat.trim(), |
598 | 598 | val, |
599 | 599 | date: editDate, |
600 | | - account_id: editAccountId === "" ? null : editAccountId, |
| 600 | + account_id: editAccountId === "" ? undefined : editAccountId, |
601 | 601 | }); |
602 | 602 | editingId = null; |
603 | 603 | await loadRecords(); |
|
975 | 975 | bind:value={eCat} |
976 | 976 | /> |
977 | 977 | <datalist id="exp-cats-list"> |
978 | | - {#each expCategories as c}<option |
979 | | - value={c} |
980 | | - />{/each} |
| 978 | + {#each expCategories as c}<option value={c}></option>{/each} |
981 | 979 | </datalist> |
982 | 980 | </div> |
983 | 981 | <input class="ii t" type="date" bind:value={eDate} /> |
|
1043 | 1041 | bind:value={rCat} |
1044 | 1042 | /> |
1045 | 1043 | <datalist id="rev-cats-list"> |
1046 | | - {#each revCategories as c}<option |
1047 | | - value={c} |
1048 | | - />{/each} |
| 1044 | + {#each revCategories as c}<option value={c}></option>{/each} |
1049 | 1045 | </datalist> |
1050 | 1046 | </div> |
1051 | 1047 | <input class="ii t" type="date" bind:value={rDate} /> |
|
1964 | 1960 | .var-val.dn { |
1965 | 1961 | color: var(--red); |
1966 | 1962 | } |
1967 | | - .var-title { |
1968 | | - font-family: "Caveat Brush", cursive; |
1969 | | - font-size: 13px; |
1970 | | - letter-spacing: 0.12em; |
1971 | | - text-transform: uppercase; |
1972 | | - color: var(--ink-faint); |
1973 | | - margin-bottom: 10px; |
1974 | | - } |
1975 | | -
|
1976 | 1963 | /* ── DOUBLE RULE ── */ |
1977 | 1964 | .drule { |
1978 | 1965 | border: none; |
|
0 commit comments