started to implement updates on transactions
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
49
frontend/src/routes/accounting/transaction.svelte
Normal file
49
frontend/src/routes/accounting/transaction.svelte
Normal file
@@ -0,0 +1,49 @@
|
||||
<script>
|
||||
import LineEditor from '../../Components/LineEditor.svelte';
|
||||
import { api, patch } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
let { account, transaction, users } = $props();
|
||||
|
||||
async function update(changes){
|
||||
let url = api('accounting/transaction/'+transaction.id);
|
||||
let res = await patch(url,changes);
|
||||
if (res.ok){
|
||||
yikes();
|
||||
return true;
|
||||
}
|
||||
error(res);
|
||||
return false;
|
||||
}
|
||||
|
||||
async function setDate(newDate){
|
||||
return await update({date:newDate});
|
||||
}
|
||||
</script>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<LineEditor type="date" wrapper="span" editable="true" value={transaction.date} onSet={setDate} />
|
||||
</td>
|
||||
{#each Object.entries(users) as [id,user]}
|
||||
<td class="amount">
|
||||
{#if id == transaction.source.id}
|
||||
{(-transaction.amount).toFixed(2)} {account.currency}
|
||||
{/if}
|
||||
{#if id == transaction.destination.id}
|
||||
{(+transaction.amount).toFixed(2)} {account.currency}
|
||||
{/if}
|
||||
</td>
|
||||
{/each}
|
||||
<td class="party">
|
||||
{#if !transaction.source.id}
|
||||
← {transaction.source.value}
|
||||
{/if}
|
||||
{#if !transaction.destination.id}
|
||||
→ {transaction.destination.value}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="purpose">{transaction.purpose}</td>
|
||||
<td class="tags">
|
||||
{transaction.tags.join(', ')}
|
||||
</td>
|
||||
</tr>
|
||||
Reference in New Issue
Block a user