implemented purpose proposals based on source, dest and amount

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-05-03 14:01:58 +02:00
parent 170a551169
commit 854cdded3d
5 changed files with 67 additions and 5 deletions
+1 -1
View File
@@ -145,7 +145,7 @@
</style>
<span class="autocomplete">
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} />
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} />
{#if candidates && candidates.length > 0}
<ul bind:this={list_elem} class="suggestions">
{#each candidates as candidate,i}
@@ -42,7 +42,10 @@
}
function focusOnEnter(ev,id){
if (ev.key == 'Enter') document.getElementById(id).focus();
if (ev.key == 'Enter') {
proposePurpose();
document.getElementById(id).focus();
}
}
async function getAccountTags(text){
@@ -93,6 +96,20 @@
}
}
async function proposePurpose(){
const source = entry.source;
const destination = entry.destination;
const amount = entry.amount;
const url = api(`accounting/${account.id}/purposes`);
const res = await post(url,{source,destination,amount});
if (res.ok) {
yikes();
var lastTransaction = await res.json();
entry.purpose = { display: lastTransaction.purpose};
entry.tags = lastTransaction.tags;
} else error(res);
}
async function save(){
let data = {
...entry,
@@ -169,4 +186,4 @@
<span>
<button onclick={save}>{t('save')}</button>
</span>
</fieldset>
</fieldset>