first working version where transactions can be stored

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-04-03 00:52:13 +02:00
parent 087c2ef95e
commit eddd4d9b51
9 changed files with 155 additions and 89 deletions

View File

@@ -7,18 +7,19 @@
import { user } from '../../user.svelte';
import Autocomplete from '../../Components/Autocomplete.svelte';
let { new_account = false } = $props();
let defaultAccount = {
id : 0,
name : '',
currency : ''
};
let { account = defaultAccount, new_account = false } = $props();
let entry = $state({
account : {
id : 0,
name : '',
currency : ''
},
account,
date : new Date().toISOString().substring(0, 10),
source : {
display: user.name,
user_id: user.id
id: user.id
},
destination : {},
amount : 0.0,
@@ -26,6 +27,19 @@
});
let router = useTinyRouter();
async function getUsers(text){
var url = api('user/search');
var res = await post(url,text);
if (res.ok){
yikes();
const input = await res.json();
return Object.values(input).map(user => { return {...user, display: user.name}});
} else {
error(res);
return {};
}
}
async function save(){
let data = {
...entry,
@@ -68,10 +82,10 @@
<input type="date" value={entry.date} />
<span>{t('source')}</span>
<Autocomplete bind:candidate={entry.source} />
<Autocomplete bind:candidate={entry.source} getCandidates={getUsers} />
<span>{t('destination')}</span>
<Autocomplete bind:candidate={entry.destination} />
<Autocomplete bind:candidate={entry.destination} getCandidates={getUsers} />
<span>{t('amount')}</span>
<span>