first working version where transactions can be stored
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -4,18 +4,23 @@
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte';
|
||||
|
||||
let { id } = $props();
|
||||
let account = $state(null);
|
||||
import EntryForm from './add_entry.svelte';
|
||||
|
||||
let { id } = $props();
|
||||
let account = $state(null);
|
||||
let transactions = [];
|
||||
let users = {};
|
||||
|
||||
async function load(){
|
||||
let url = api(`accounting/${id}`);
|
||||
let res = await get(url);
|
||||
if (res.ok) {
|
||||
yikes();
|
||||
let json = await res.json();
|
||||
let json = await res.json();
|
||||
transactions = json.transactions;
|
||||
account = json.account;
|
||||
users = json.user_list;
|
||||
account = json.account;
|
||||
console.log(users);
|
||||
} else error(res);
|
||||
}
|
||||
|
||||
@@ -28,9 +33,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t('date')}</th>
|
||||
<th>{t('source')}</th>
|
||||
<th>{t('destination')}</th>
|
||||
<th>{t('amount')}</th>
|
||||
{#each Object.entries(users) as [id,user]}
|
||||
<th>{user.name}</th>
|
||||
{/each}
|
||||
<th>{t('other party')}</th>
|
||||
<th>{t('purpose')}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -38,13 +44,30 @@
|
||||
{#each transactions as transaction, i}
|
||||
<tr>
|
||||
<td>{transaction.date}</td>
|
||||
<td>{transaction.source}</td>
|
||||
<td>{transaction.destination}</td>
|
||||
<td>{transaction.amount} {account.currency}</td>
|
||||
{#each Object.entries(users) as [id,user]}
|
||||
<td>
|
||||
{#if id == transaction.source.id}
|
||||
{-transaction.amount} {account.currency}
|
||||
{/if}
|
||||
{#if id == transaction.destination.id}
|
||||
{transaction.amount} {account.currency}
|
||||
{/if}
|
||||
</td>
|
||||
{/each}
|
||||
<td>
|
||||
{#if !transaction.source.id}
|
||||
{transaction.source.value}
|
||||
{/if}
|
||||
{#if !transaction.destination.id}
|
||||
{transaction.destination.value}
|
||||
{/if}
|
||||
</td>
|
||||
<td>{transaction.purpose}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<EntryForm {account} />
|
||||
{/if}
|
||||
Reference in New Issue
Block a user