diff --git a/src/routes/expense/+page.svelte b/src/routes/expense/+page.svelte index 8fa4e67..46a09a9 100644 --- a/src/routes/expense/+page.svelte +++ b/src/routes/expense/+page.svelte @@ -143,6 +143,16 @@ target.value = NumberToFPA(currentExpense.value); } + function getBalanceOfSelectedCardAfterExpense(): string { + if (currentExpense.card_id == 0 || currentExpense.value == 0) { + return ""; + } + const selectedCard = cards.find( + (card) => card.id == currentExpense.card_id, + ); + return `Value of ${selectedCard?.display_name} after expense = ${NumberToFPA(Number(selectedCard?.balance) - Number(currentExpense.value))}`; + } + const constructedTime = $derived(`${mutateDate}T${selectedTime}Z`); const currentExpense = $derived(editingExpense ?? newExpense); const selectedType = $derived( @@ -231,6 +241,7 @@ /> + {getBalanceOfSelectedCardAfterExpense()}