extended possibilities to edit transaction
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -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)} {account.currency}
|
||||
-<LineEditor type="number" wrapper="span" editable="true" value={(+transaction.amount).toFixed(2)} onSet={setAmount} /> {account.currency}
|
||||
{/if}
|
||||
{#if id == transaction.destination.id}
|
||||
{(+transaction.amount).toFixed(2)} {account.currency}
|
||||
<LineEditor type="number" wrapper="span" editable="true" value={(+transaction.amount).toFixed(2)} onSet={setAmount} /> {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">
|
||||
|
||||
Reference in New Issue
Block a user