extended possibilities to edit transaction

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-04-10 16:08:03 +02:00
parent 0c6e5850d2
commit 9d9e2ed50b
3 changed files with 45 additions and 14 deletions

View File

@@ -4,6 +4,25 @@
import { error, yikes } from '../../warn.svelte';
let { account, transaction, users } = $props();
async function setAmount(amount){
return await update({amount});
}
async function setDate(date){
return await update({date});
}
async function setDestination(destination){
return await update({destination});
}
async function setPurpose(purpose){
return await update({purpose});
}
async function setSource(source){
return await update({source});
}
async function update(changes){
let url = api('accounting/transaction/'+transaction.id);
let res = await patch(url,changes);
@@ -14,14 +33,6 @@
error(res);
return false;
}
async function setDate(date){
return await update({date});
}
async function setPurpose(purpose){
return await update({purpose});
}
</script>
<tr>
@@ -31,19 +42,19 @@
{#each Object.entries(users) as [id,user]}
<td class="amount">
{#if id == transaction.source.id}
{(-transaction.amount).toFixed(2)}&nbsp;{account.currency}
-<LineEditor type="number" wrapper="span" editable="true" value={(+transaction.amount).toFixed(2)} onSet={setAmount} />&nbsp;{account.currency}
{/if}
{#if id == transaction.destination.id}
{(+transaction.amount).toFixed(2)}&nbsp;{account.currency}
<LineEditor type="number" wrapper="span" editable="true" value={(+transaction.amount).toFixed(2)} onSet={setAmount} />&nbsp;{account.currency}
{/if}
</td>
{/each}
<td class="party">
{#if !transaction.source.id}
{transaction.source.value}
<LineEditor wrapper="span" editable="true" value={transaction.source.value} onSet={setSource} />
{/if}
{#if !transaction.destination.id}
{transaction.destination.value}
<LineEditor wrapper="span" editable="true" value={transaction.destination.value} onSet={setDestination} />
{/if}
</td>
<td class="purpose">