preparing tagging of transactions
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -9,6 +9,7 @@ import static de.srsoftware.umbrella.core.Util.mapValues;
|
|||||||
import static de.srsoftware.umbrella.core.constants.Path.*;
|
import static de.srsoftware.umbrella.core.constants.Path.*;
|
||||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidField;
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidField;
|
||||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingField;
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingField;
|
||||||
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
|
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
import de.srsoftware.configuration.Configuration;
|
import de.srsoftware.configuration.Configuration;
|
||||||
@@ -28,6 +29,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class AccountingModule extends BaseHandler implements AccountingService {
|
public class AccountingModule extends BaseHandler implements AccountingService {
|
||||||
@@ -179,6 +182,8 @@ public class AccountingModule extends BaseHandler implements AccountingService {
|
|||||||
|
|
||||||
var transaction = accountDb.save(new Transaction(accountId,dateTime,source,destination,amount.doubleValue(),purpose));
|
var transaction = accountDb.save(new Transaction(accountId,dateTime,source,destination,amount.doubleValue(),purpose));
|
||||||
|
|
||||||
|
var tags = json.has(Field.TAGS) && json.get(Field.TAGS) instanceof JSONArray t ? t : null;
|
||||||
|
if (tags != null) LOG.log(WARNING, "Tagging transactions not implemented!");
|
||||||
return sendContent(ex,newAccount != null ? newAccount : transaction);
|
return sendContent(ex,newAccount != null ? newAccount : transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class SqliteDb extends BaseDb implements AccountDb {
|
|||||||
public List<Transaction> loadTransactions(Account account) {
|
public List<Transaction> loadTransactions(Account account) {
|
||||||
try {
|
try {
|
||||||
var list = new ArrayList<Transaction>();
|
var list = new ArrayList<Transaction>();
|
||||||
var rs = select(ALL).from(TABLE_TRANSACTIONS).where(Field.ACCOUNT,equal(account.id())).exec(db);
|
var rs = select(ALL).from(TABLE_TRANSACTIONS).where(Field.ACCOUNT,equal(account.id())).sort(Field.TIMESTAMP).exec(db);
|
||||||
while (rs.next()) list.add(Transaction.of(rs));
|
while (rs.next()) list.add(Transaction.of(rs));
|
||||||
rs.close();
|
rs.close();
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { error, yikes } from '../../warn.svelte';
|
import { error, yikes } from '../../warn.svelte';
|
||||||
import { user } from '../../user.svelte';
|
import { user } from '../../user.svelte';
|
||||||
import Autocomplete from '../../Components/Autocomplete.svelte';
|
import Autocomplete from '../../Components/Autocomplete.svelte';
|
||||||
|
import Tags from '../tags/TagList.svelte';
|
||||||
|
|
||||||
let defaultAccount = {
|
let defaultAccount = {
|
||||||
id : 0,
|
id : 0,
|
||||||
@@ -23,7 +24,8 @@
|
|||||||
},
|
},
|
||||||
destination : {},
|
destination : {},
|
||||||
amount : 0.0,
|
amount : 0.0,
|
||||||
purpose : {}
|
purpose : {},
|
||||||
|
tags : []
|
||||||
});
|
});
|
||||||
let router = useTinyRouter();
|
let router = useTinyRouter();
|
||||||
|
|
||||||
@@ -73,6 +75,7 @@
|
|||||||
let res = await post(url, data);
|
let res = await post(url, data);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
yikes();
|
yikes();
|
||||||
|
entry.tags = [];
|
||||||
onSave();
|
onSave();
|
||||||
document.getElementById('date-input').focus();
|
document.getElementById('date-input').focus();
|
||||||
} else error(res);
|
} else error(res);
|
||||||
@@ -130,6 +133,9 @@
|
|||||||
<span>{t('purpose')}</span>
|
<span>{t('purpose')}</span>
|
||||||
<Autocomplete bind:candidate={entry.purpose} getCandidates={getPurposes} />
|
<Autocomplete bind:candidate={entry.purpose} getCandidates={getPurposes} />
|
||||||
|
|
||||||
|
<span>{t('tags')}</span>
|
||||||
|
<Tags module={null} bind:tags={entry.tags} />
|
||||||
|
|
||||||
<span></span>
|
<span></span>
|
||||||
<span>
|
<span>
|
||||||
<button onclick={save}>{t('save')}</button>
|
<button onclick={save}>{t('save')}</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user