Add usefull function that will show balance of selected card on expense page after expense
This commit is contained in:
parent
377c928372
commit
aeaef4fbd3
|
@ -143,6 +143,16 @@
|
||||||
target.value = NumberToFPA(currentExpense.value);
|
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 constructedTime = $derived(`${mutateDate}T${selectedTime}Z`);
|
||||||
const currentExpense = $derived(editingExpense ?? newExpense);
|
const currentExpense = $derived(editingExpense ?? newExpense);
|
||||||
const selectedType = $derived(
|
const selectedType = $derived(
|
||||||
|
@ -231,6 +241,7 @@
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<span>{getBalanceOfSelectedCardAfterExpense()}</span>
|
||||||
|
|
||||||
<div class="flex space-x-2">
|
<div class="flex space-x-2">
|
||||||
<button
|
<button
|
||||||
|
|
Loading…
Reference in New Issue
Block a user