Compare commits

...

17 Commits

Author SHA1 Message Date
StephanRichter fe57749d9c improving note lsit
Build Docker Image / Docker-Build (push) Successful in 2m39s
Build Docker Image / Clean-Registry (push) Successful in 3s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-06 09:25:45 +02:00
StephanRichter d3f9ca2c5d Merge commit '2adba956debba2792a3e88ebb70226071949ef0a' into accounting
Build Docker Image / Docker-Build (push) Successful in 2m33s
Build Docker Image / Clean-Registry (push) Successful in 3s
2026-05-06 08:43:04 +02:00
StephanRichter fe18cb8dc2 implemented security measures for account management
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-06 08:37:24 +02:00
StephanRichter 20f47055f6 minor css fix
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-06 08:20:37 +02:00
StephanRichter c6caf7aacc improving messages
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-06 08:20:37 +02:00
StephanRichter cc3a3a23a2 implemented proper messages for accounting events
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-06 08:20:37 +02:00
StephanRichter cfd5362b1d implemented message on transaction creation/update
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-06 08:20:37 +02:00
StephanRichter ca24ada1fd implemented transaction propagation via event bus
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-06 08:20:37 +02:00
StephanRichter 2adba956de minor css fix
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-05 22:56:19 +02:00
StephanRichter 3a2ab75b15 improving messages
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-05 20:34:47 +02:00
StephanRichter 719558e8ee implemented proper messages for accounting events
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-05 10:01:03 +02:00
StephanRichter 80311c8493 fixed css class
Build Docker Image / Docker-Build (push) Successful in 2m31s
Build Docker Image / Clean-Registry (push) Successful in 3s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-05 08:27:06 +02:00
StephanRichter 713edd3638 implemented message on transaction creation/update
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-04 22:38:11 +02:00
StephanRichter e43ab1f20e implemented transaction propagation via event bus
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-04 22:15:58 +02:00
StephanRichter 9417c60346 Merge branch 'accounting'
Build Docker Image / Docker-Build (push) Successful in 2m36s
Build Docker Image / Clean-Registry (push) Successful in 4s
2026-05-04 20:57:29 +02:00
StephanRichter f8db846369 Merge branch 'improvement/autocomplete'
Build Docker Image / Docker-Build (push) Successful in 3m3s
Build Docker Image / Clean-Registry (push) Successful in 4s
2026-05-04 20:53:48 +02:00
StephanRichter 71309011a0 improving autocomplete
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-04-24 11:45:34 +02:00
22 changed files with 256 additions and 42 deletions
+1
View File
@@ -1,5 +1,6 @@
description = "Umbrella : Accounting"
dependencies{
implementation(project(":bus"))
implementation(project(":core"))
}
@@ -3,14 +3,19 @@ package de.srsoftware.umbrella.accounting;
import de.srsoftware.umbrella.core.model.Account;
import de.srsoftware.umbrella.core.model.Transaction;
import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
public interface AccountDb {
Transaction dropTransaction(Transaction transaction);
void dropTransactionTag(long transactionId, String tag);
Collection<UmbrellaUser> getMembers(long accountId);
Optional<Transaction> lastTransaction(long accountId, String source, String dest, double amount);
Collection<Account> listAccounts(long userId);
@@ -6,11 +6,10 @@ import static de.srsoftware.umbrella.accounting.Constants.CONFIG_DATABASE;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.ModuleRegistry.tagService;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Util.mapValues;
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.missingField;
import static java.lang.System.Logger.Level.WARNING;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.CREATE;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration;
@@ -23,6 +22,8 @@ import de.srsoftware.umbrella.core.constants.Field;
import de.srsoftware.umbrella.core.constants.Text;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.core.model.*;
import de.srsoftware.umbrella.messagebus.events.Event;
import de.srsoftware.umbrella.messagebus.events.TransactionEvent;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -52,6 +53,7 @@ public class AccountingModule extends BaseHandler implements AccountingService {
case TRANSACTION -> {
try {
var transaction = accountDb.loadTransaction(Long.parseLong(path.pop()));
if (!accountDb.getMembers(transaction.accountId()).contains(user.get())) throw forbidden("You are not allowed to access account {id}",Field.ID,transaction.accountId());
yield dropTransaction(transaction, user.get(), path, ex);
} catch (NumberFormatException ignored) {
yield super.doDelete(path,ex);
@@ -125,6 +127,7 @@ public class AccountingModule extends BaseHandler implements AccountingService {
default -> {
try {
var accountId = Long.parseLong(head);
if (!accountDb.getMembers(accountId).contains(user.get())) throw forbidden("You are not allowed to access account {id}",Field.ID,accountId);
yield postToAccount(accountId,path,user.get(),ex);
} catch (NumberFormatException ignored) {
yield super.doPost(path,ex);
@@ -137,16 +140,22 @@ public class AccountingModule extends BaseHandler implements AccountingService {
}
}
public boolean dropTransaction(Transaction transaction, UmbrellaUser user, HttpExchange ex) throws IOException {
var dropped = accountDb.dropTransaction(transaction);
messageBus().dispatch(new TransactionEvent(user,dropped,Event.EventType.DELETE));
return sendContent(ex,dropped);
}
public boolean dropTransaction(Transaction transaction, UmbrellaUser user, Path path, HttpExchange ex) throws IOException {
var head = path.pop();
return switch (head){
case TAG -> dropTransactionTag(user,transaction,ex);
case null, default -> super.doDelete(path,ex);
case null -> dropTransaction(transaction,user,ex);
default -> super.doDelete(path,ex);
};
}
private boolean dropTransactionTag(UmbrellaUser user, Transaction transaction, HttpExchange ex) throws IOException {
LOG.log(WARNING,"Missing permission check in AccountModule.dropTransactionTag!");
var json = json(ex);
if (!json.has(Field.TAG)) throw missingField(Field.TAG);
var tag = json.getString(Field.TAG);
@@ -176,7 +185,15 @@ public class AccountingModule extends BaseHandler implements AccountingService {
}
private boolean getAccount(UmbrellaUser user, long accountId, HttpExchange ex) throws IOException {
LOG.log(WARNING,"Missing authorization check in AccountingModule.getAccount(…)!");
if (!accountDb.getMembers(accountId).contains(user)) throw forbidden("You are not allowed to access account {id}",Field.ID,accountId);
return sendContent(ex, loadAccount(accountId));
}
private boolean getAccounts(UmbrellaUser user, HttpExchange ex) throws IOException {
return sendContent(ex,accountDb.listAccounts(user.id()).stream().map(Account::toMap));
}
public AccountData loadAccount(long accountId){
var account = accountDb.loadAccount(accountId);
var transactions = accountDb.loadTransactions(account);
var userMap = new HashMap<Long,UmbrellaUser>();
@@ -193,20 +210,9 @@ public class AccountingModule extends BaseHandler implements AccountingService {
if (!userMap.containsKey(userId)) userMap.put(destination.id(),userService().loadUser(userId));
}
}
return sendContent(ex, Map.of(
Field.ACCOUNT,account.toMap(),
Field.TRANSACTIONS,transactions.stream().map(Transaction::toMap).toList(),
Field.USER_LIST,mapValues(userMap)
));
return AccountData.of(account, transactions, userMap);
}
private boolean getAccounts(UmbrellaUser user, HttpExchange ex) throws IOException {
return sendContent(ex,accountDb.listAccounts(user.id()).stream().map(Account::toMap));
}
private static boolean noNumbers(String s){
try {
Long.parseLong(s);
@@ -218,7 +224,8 @@ public class AccountingModule extends BaseHandler implements AccountingService {
private boolean patchTransaction(UmbrellaUser user, long transactionId, HttpExchange ex) throws IOException {
var transaction = accountDb.loadTransaction(transactionId);
LOG.log(WARNING,"Missing permission check in patchTransaction(…)!");
if (!accountDb.getMembers(transaction.accountId()).contains(user)) throw forbidden("You are not allowed to access account {id}",Field.ID,transaction.accountId());
var oldData = transaction.toMap();
var json = json(ex);
if (json.has(Field.AMOUNT)) transaction.amount(json.getDouble(Field.AMOUNT));
if (json.has(Field.DATE)) transaction.date(LocalDate.parse(json.getString(Field.DATE)));
@@ -226,7 +233,9 @@ public class AccountingModule extends BaseHandler implements AccountingService {
if (json.has(Field.PURPOSE)) transaction.purpose(json.getString(Field.PURPOSE));
if (json.has(Field.SOURCE)) transaction.source(IdOrString.of(json.getString(Field.SOURCE)));
if (json.has(Field.TAG)) transaction.tags().add(json.getString(Field.TAG));
return sendContent(ex,accountDb.save(transaction));
var patched = accountDb.save(transaction);
messageBus().dispatch(new TransactionEvent(user,patched,oldData));
return sendContent(ex,patched);
}
private boolean postEntry(UmbrellaUser user, HttpExchange ex) throws IOException {
@@ -291,7 +300,7 @@ public class AccountingModule extends BaseHandler implements AccountingService {
var transaction = accountDb.save(new Transaction(0,accountId,dateTime,source,destination,amount.doubleValue(),purpose,tags));
messageBus().dispatch(new TransactionEvent(user,transaction, CREATE));
return sendContent(ex,newAccount != null ? newAccount : transaction);
}
@@ -327,7 +336,6 @@ public class AccountingModule extends BaseHandler implements AccountingService {
}
private boolean postSearchTags(long accountId, UmbrellaUser user, HttpExchange ex) throws IOException {
LOG.log(WARNING,"Missing authorization check in AccountingModule.getAccount(…)!");
var key = body(ex);
if (!key.trim().startsWith("{")) { // search tags that contain value of body
var tags = accountDb.searchTagsContaining(key, accountId);
@@ -7,6 +7,7 @@ import static de.srsoftware.tools.jdbc.Condition.*;
import static de.srsoftware.tools.jdbc.Query.*;
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
import static de.srsoftware.umbrella.accounting.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.constants.Field.*;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
import static de.srsoftware.umbrella.core.model.Translatable.t;
@@ -19,6 +20,7 @@ import de.srsoftware.umbrella.core.constants.Field;
import de.srsoftware.umbrella.core.constants.Text;
import de.srsoftware.umbrella.core.model.Account;
import de.srsoftware.umbrella.core.model.Transaction;
import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.sql.Connection;
import java.sql.SQLException;
import java.time.ZoneOffset;
@@ -117,6 +119,21 @@ public class SqliteDb extends BaseDb implements AccountDb {
}
}
public Transaction dropTransaction(Transaction transaction){
try {
db.setAutoCommit(false);
Query.delete().from(TABLE_TAGS_TRANSACTIONS).where(TRANSACTION_ID,equal(transaction.id())).execute(db);
Query.delete().from(TABLE_TRANSACTIONS).where(ID,equal(transaction.id())).execute(db);
db.setAutoCommit(true);
return transaction;
} catch (SQLException e){
try {
db.rollback();
} catch (SQLException ignored){};
throw failedToDropObject(transaction);
}
}
@Override
public void dropTransactionTag(long transactionId, String tag) {
try {
@@ -131,6 +148,27 @@ public class SqliteDb extends BaseDb implements AccountDb {
}
}
@Override
public Collection<UmbrellaUser> getMembers(long accountId) {
try {
var userIds = new HashSet<Long>();
var rs = select("DISTINCT "+ SOURCE).from(TABLE_TRANSACTIONS).where(ACCOUNT,equal(accountId)).exec(db);
while (rs.next()) try {
userIds.add(Long.parseLong(rs.getString(1)));
} catch (NumberFormatException ignored) {}
rs.close();
rs = select("DISTINCT "+ DESTINATION).from(TABLE_TRANSACTIONS).where(ACCOUNT,equal(accountId)).exec(db);
while (rs.next()) try {
userIds.add(Long.parseLong(rs.getString(1)));
} catch (NumberFormatException ignored) {}
rs.close();
var us = userService();
return userIds.stream().map(us::loadUser).toList();
} catch (SQLException e) {
throw failedToLoadMembers(Text.ACCOUNT);
}
}
@Override
public Optional<Transaction> lastTransaction(long accountId, String source, String dest, double amount) {
try {
@@ -295,13 +333,9 @@ public class SqliteDb extends BaseDb implements AccountDb {
}
} else if (transaction.isDirty()) {
try {
if (transaction.amount() == 0 || transaction.source().isEmpty() || transaction.destination().isEmpty()) {
delete().from(TABLE_TRANSACTIONS).where(Field.ID, equal(transaction.id())).where(ACCOUNT, equal(transaction.accountId())).execute(db);
} else {
replaceInto(TABLE_TRANSACTIONS, Field.ID, Field.ACCOUNT, Field.TIMESTAMP, Field.SOURCE, Field.DESTINATION, Field.AMOUNT, Field.DESCRIPTION)
.values(transaction.id(), transaction.accountId(), timestamp, transaction.source().value(), transaction.destination().value(), transaction.amount(), transaction.purpose())
.execute(db).close();
}
replaceInto(TABLE_TRANSACTIONS, Field.ID, Field.ACCOUNT, Field.TIMESTAMP, Field.SOURCE, Field.DESTINATION, Field.AMOUNT, Field.DESCRIPTION)
.values(transaction.id(), transaction.accountId(), timestamp, transaction.source().value(), transaction.destination().value(), transaction.amount(), transaction.purpose())
.execute(db).close();
return transaction.clearDirtyState();
} catch (SQLException e) {
throw failedToStoreObject(transaction);
@@ -65,7 +65,7 @@ public class MessageApi extends BaseHandler{
}
}
private void sendEvent(PrintWriter out, Event event) {
private void sendEvent(PrintWriter out, Event<?> event) {
if (event == null) return;
out.print("event: ");
out.println(event.eventType());
@@ -0,0 +1,76 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.messagebus.events;
import static de.srsoftware.umbrella.core.ModuleRegistry.accountingService;
import static de.srsoftware.umbrella.core.constants.Field.*;
import static de.srsoftware.umbrella.core.model.Translatable.t;
import de.srsoftware.umbrella.core.constants.Field;
import de.srsoftware.umbrella.core.constants.Module;
import de.srsoftware.umbrella.core.constants.Text;
import de.srsoftware.umbrella.core.model.Transaction;
import de.srsoftware.umbrella.core.model.Translatable;
import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.util.Collection;
import java.util.Map;
public class TransactionEvent extends Event<Transaction> {
private Collection<UmbrellaUser> audience;
public TransactionEvent(UmbrellaUser initiator, Transaction transaction, EventType type) {
super(initiator, Module.ACCOUNTING, transaction, type);
audience = null;
}
public TransactionEvent(UmbrellaUser initiator, Transaction transaction, Map<String, Object> oldData){
super(initiator,Module.ACCOUNTING,transaction,oldData);
}
@Override
public Collection<UmbrellaUser> audience() {
if (audience == null) audience = accountingService().loadAccount(payload().accountId()).userMap().values();
return audience;
}
@Override
public Translatable describe() {
var user = initiator().name();
var type = t(Text.TRANSACTION);
var entity = payload().purpose();
return switch (eventType()){
case CREATE -> describeDetail();
case DELETE -> describeDetail();
case UPDATE -> describeUpdate();
case null, default -> t("TODO"); // TODO
};
}
private Translatable describeUpdate() {
var head = t("Changes in {type} '{entity}':\n\n{body}",Field.TYPE,t(Text.TRANSACTION),Field.ENTITY,oldData().get(PURPOSE),BODY,diff().orElse(""));
return t("{head}\n\n{link}","head",head,"link",link());
}
private Translatable describeDetail(){
var tr = payload();
var message = "{source}: {source_name}\n{destination}: {dest_name}\n{amount}: {value}\n{purpose}: {purpose_val}\n\n{link}";
return t(message,SOURCE,t(Text.SOURCE), "source_name",tr.source(), DESTINATION,t(Text.DESTINATION),"dest_name",tr.destination(), AMOUNT,t(Text.AMOUNT), VALUE,tr.amount(), PURPOSE,t(Text.PURPOSE),"purpose_val",tr.purpose(),"link",link());
}
private Translatable link() {
return t("You can view/edit this transaction at {base_url}/account/{id}", ID, payload().accountId());
}
@Override
public Translatable subject() {
var user = initiator().name();
var entity = payload().purpose();
return switch (eventType()){
case CREATE -> t("{user} added a new transaction: {entity}", USER,user, ENTITY, entity);
case DELETE -> t("The transaction '{entity}' has been deleted by {user}",Field.ENTITY, entity, USER, user);
case UPDATE -> t("{user} updated the transaction '{entity}'", USER,user, ENTITY, oldData().get(PURPOSE));
case null, default -> t("TODO"); // TODO
};
}
}
@@ -53,6 +53,10 @@ public class ModuleRegistry {
}
}
public static AccountingService accountingService() {
return singleton.accountingService;
}
public static BookmarkService bookmarkService(){
return singleton.bookmarkService;
}
@@ -1,5 +1,32 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.api;
import static de.srsoftware.umbrella.core.Util.mapValues;
import de.srsoftware.tools.Mappable;
import de.srsoftware.umbrella.core.constants.Field;
import de.srsoftware.umbrella.core.model.Account;
import de.srsoftware.umbrella.core.model.Transaction;
import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public interface AccountingService {
public record AccountData(Account account, List<Transaction> transactions, HashMap<Long, UmbrellaUser> userMap) implements Mappable {
public static AccountData of(Account account, List<Transaction> transactions, HashMap<Long, UmbrellaUser> userMap) {
return new AccountData(account, transactions, userMap);
}
@Override
public Map<String, Object> toMap() {
return Map.of(
Field.ACCOUNT,account.toMap(),
Field.TRANSACTIONS,transactions.stream().map(Transaction::toMap).toList(),
Field.USER_LIST,mapValues(userMap)
);
}
}
AccountData loadAccount(long accountId);
}
@@ -57,6 +57,7 @@ public class Field {
public static final String EDITOR = "editor";
public static final String EMAIL = "email";
public static final String END_TIME = "end_time";
public static final String ENTITY = "entity";
public static final String ENTITY_ID = "entity_id";
public static final String EST_TIME = "est_time";
public static final String EVALUATION = "evaluation";
@@ -7,6 +7,7 @@ package de.srsoftware.umbrella.core.constants;
public class Text {
public static final String ACCOUNT = "account";
public static final String ACCOUNTING = "accounting";
public static final String AMOUNT = "amount";
public static final String BOOKMARK = "bookmark";
public static final String BOOKMARKS = "bookmarks";
@@ -21,6 +22,7 @@ public class Text {
public static final String CUSTOMER = "customer";
public static final String CUSTOMER_SETTINGS = "customer settings";
public static final String DESTINATION = "destination";
public static final String DOCUMENT = "document";
public static final String DOCUMENTS = "documents";
public static final String DOCUMENT_TYPE_ID = "document type id";
@@ -60,6 +62,7 @@ public class Text {
public static final String PROJECT_WITH_ID = "project ({id})";
public static final String PROPERTIES = "properties";
public static final String PROPERTY = "property";
public static final String PURPOSE = "purpose";
public static final String RECEIVER = "receiver";
public static final String RECEIVERS = "receivers";
@@ -69,6 +72,7 @@ public class Text {
public static final String SERVICE_WITH_ID = "service ({id})";
public static final String SESSION = "session";
public static final String SETTINGS = "settings";
public static final String SOURCE = "source";
public static final String STOCK = "stock";
public static final String STRING = "string";
@@ -1,14 +1,13 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
import static de.srsoftware.tools.Optionals.isSet;
import de.srsoftware.tools.Mappable;
import de.srsoftware.umbrella.core.constants.Field;
import java.util.HashMap;
import java.util.Map;
import static de.srsoftware.tools.Optionals.isSet;
import static de.srsoftware.tools.Optionals.nullIfEmpty;
public class IdOrString implements Mappable {
private final Long id;
private final String value;
@@ -16,6 +16,7 @@ import static de.srsoftware.umbrella.core.ModuleRegistry.*;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.constants.Field.*;
import static de.srsoftware.umbrella.core.constants.Field.AMOUNT;
import static de.srsoftware.umbrella.core.constants.Field.COMPANY;
import static de.srsoftware.umbrella.core.constants.Field.CUSTOMER;
import static de.srsoftware.umbrella.core.constants.Field.DOCUMENT;
@@ -9,6 +9,7 @@ import static de.srsoftware.umbrella.core.Errors.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.translator;
import static de.srsoftware.umbrella.core.constants.Constants.FALLBACK_LANG;
import static de.srsoftware.umbrella.core.constants.Field.*;
import static de.srsoftware.umbrella.core.constants.Field.AMOUNT;
import static de.srsoftware.umbrella.core.constants.Field.COMPANY;
import static de.srsoftware.umbrella.core.constants.Field.CUSTOMER;
import static de.srsoftware.umbrella.core.constants.Field.NUMBER;
+1 -1
View File
@@ -132,7 +132,7 @@
color: orange;
border: 1px solid orange;
border-radius: 5px;
z-index: 50;
z-index: 65;
list-style: none;
padding: 4px;
margin: 0;
@@ -155,7 +155,7 @@
{/if}
{:else}
<Display classes={{editable}} markdown={value} {onclick} {oncontextmenu} title={t('right_click_to_edit')} wrapper={type} />
{#if !value.display}
{#if !value.rendered}
<button onclick={oncontextmenu}>{t('add_object',{object:t('content')})}</button>
{/if}
{/if}
+33 -4
View File
@@ -1,6 +1,6 @@
<script>
import { onMount } from 'svelte';
import { api, get } from '../../urls.svelte';
import { api, eventStream, get } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
@@ -9,6 +9,7 @@
let { id } = $props();
let account = $state(null);
let eventSource = null;
let filter = $state([]);
let transactions = $state([]);
let filtered = $derived(transactions.filter(t => checker(t.tags,filter)));
@@ -27,7 +28,6 @@
if (!transaction.destination.id) sums[0] += transaction.amount;
if (!transaction.source.id) sums[0] -= transaction.amount;
}
window.setTimeout(scrollToBottom,100);
return sums;
}
@@ -50,6 +50,30 @@
filter = filter.filter(x => x != tag.toLowerCase());
}
function handleCreateEvent(evt){
const event_data = JSON.parse(evt.data);
const new_transaction = event_data.transaction;
transactions.push(new_transaction);
window.setTimeout(scrollToBottom,100);
}
function handleDeleteEvent(evt){
const event_data = JSON.parse(evt.data);
transactions = transactions.filter(t => t.id != event_data.transaction.id);
}
function handleUpdateEvent(evt){
const event_data = JSON.parse(evt.data);
const updated_transaction = event_data.transaction;
for (var idx in transactions){
if (transactions[idx].id == updated_transaction.id) {
updated_transaction.tags = transactions[idx].tags;
transactions[idx] = updated_transaction;
break;
}
}
}
async function load(){
let url = api(`accounting/${id}`);
let res = await get(url);
@@ -59,11 +83,15 @@
transactions = json.transactions;
users = json.user_list;
account = json.account;
try {
eventSource = eventStream(handleCreateEvent,handleUpdateEvent,handleDeleteEvent);
} catch (ignored) {}
window.setTimeout(scrollToBottom,100);
} else error(res);
}
function onSave(){
load();
// load();
}
function scrollToBottom(){
@@ -107,6 +135,7 @@
<th>{t('other party')}</th>
<th>{t('purpose')}</th>
<th>{t('tags')}</th>
<th></th>
</tr>
</thead>
<tbody>
@@ -128,7 +157,7 @@
<br/>
{sums[0].toFixed(2)}&nbsp;{account.currency}
</td>
<td colspan="2"></td>
<td colspan="3"></td>
</tr>
</tbody>
</table>
@@ -8,6 +8,16 @@
let { account, addToFilter = tag => {}, transaction, users } = $props();
let hidden = $state(false);
function deleteTransaction(ev){
if (confirm(t('confirm_delete',{element:transaction.purpose}))){
const url = api(`accounting/transaction/${transaction.id}`);
const res = drop(url);
if (res.ok){
yikes();
} else error(res);
}
}
async function dropTag(tag){
var url = api(`accounting/transaction/${transaction.id}/tag`)
var res = await drop(url,{tag});
@@ -127,5 +137,8 @@
<Autocomplete {getCandidates} {onCommit} />
</span>
</td>
<td class="actions">
<button class="symbol" onclick={deleteTransaction}></button>
</td>
</tr>
{/if}
+2 -1
View File
@@ -33,6 +33,7 @@
authors = {...authors, ...data.authors};
loader.offset += loader.limit;
loader.active = false;
console.log({authors});
yikes();
if (Object.keys(data.notes).length) onscroll(null); // when notes were received, check whether they fill up the page
@@ -78,4 +79,4 @@
</svelte:head>
<svelte:window {onscroll} />
<List {notes} />
<List {notes} {authors} />
+1
View File
@@ -64,6 +64,7 @@
<legend class="entity" onclick={() => goToEntity(note)}>{title(note)}</legend>
{/if}
<legend class="time">
{#if !module} {authors[note.user_id].name} {/if}
{note.timestamp.replace('T',' ')}
{#if user.id == note.user_id}
<button class="symbol" onclick={() => drop(note.id)}></button>
@@ -7,6 +7,7 @@ import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.constants.Field.*;
import static de.srsoftware.umbrella.core.constants.Field.PERMISSION;
import static de.srsoftware.umbrella.core.constants.Field.SETTINGS;
import static de.srsoftware.umbrella.core.constants.Field.SOURCE;
import static de.srsoftware.umbrella.core.constants.Field.TAGS;
import static de.srsoftware.umbrella.core.constants.Module.PROJECT;
import static de.srsoftware.umbrella.core.constants.Path.*;
+4
View File
@@ -397,6 +397,7 @@
"The task '{task}' has been created": "Die Aufgabe '{task}' wurde angelegt",
"The task '{task}' has been deleted": "Die Aufgabe '{task}' wurde gelöscht",
"The task '{task}' has been deleted by {user}": "Die Aufgabe '{task}' wurde von {user} gelöscht",
"The transaction '{entity}' has been deleted by {user}": "Der Umsatz „{entity}“ wurde von {user} gelöscht",
"The wiki page '{name}' has been created": "Die Wiki-Seite „{name}“ wurde angelegt",
"The wiki page '{name}' has been deleted": "Die Wiki-Seite „{name}“ wurde gelöscht.",
"The wiki page '{page}' has been deleted by {user}": "Die Wiki-Seite „{page}“ wurde durch {user} gelöscht.",
@@ -428,6 +429,8 @@
"upload_file": "Datei hochladen",
"user": "Benutzer",
"user ({id})": "Benutzer ({id})",
"{user} added a new transaction: {entity}": "{user} hat einen neuen Umsatz hinzugefügt: {entity}",
"{user} updated the transaction '{entity}'": "{user} hat den Umsatz „{entity}“ aktualisiert",
"user_list": "Benutzer-Liste",
"user_module" : "Umbrella User-Verwaltung",
"user profile": "Benutzer-Profil",
@@ -455,6 +458,7 @@
"wiki_pages": "Wiki-Seiten",
"year": "Jahr",
"You can view/edit this transaction at {base_url}/account/{id}": "Du kannst diese transaktion unter {base_url}/account/{id} ansehen",
"You can view/edit this project at {base_url}/project/{id}/view": "Du kannst dieses Projekt unter {base_url}/project/{id}/view ansehen/bearbeiten.",
"You can view/edit this task at {base_url}/task/{id}/view": "Du kannst diese Aufgabe unter {base_url}/task/{id}/view ansehen/bearbeiten.",
"You can view/edit this wiki page at {base_url}/wiki/{id}/view": "Du kannst diese Wiki-Seite unter {base_url}/wiki/{id}/view ansehen/bearbeiten.",
+5 -1
View File
@@ -397,6 +397,7 @@
"The task '{task}' has been created": "The task '{task}' has been created",
"The task '{task}' has been deleted": "The task '{task}' has been deleted",
"The task '{task}' has been deleted by {user}": "The task '{task}' has been deleted by {user}",
"The transaction '{entity}' has been deleted by {user}": "The transaction '{entity}' has been deleted by {user}",
"The wiki page '{name}' has been created": "The wiki page '{name}' has been created",
"The wiki page '{name}' has been deleted": "The wiki page '{name}' has been deleted",
"The wiki page '{page}' has been deleted by {user}": "The wiki page '{page}' has been deleted by {user}",
@@ -428,6 +429,8 @@
"upload_file": "upload file",
"user": "user",
"user ({id})": "user ({id})",
"{user} added a new transaction: {entity}": "{user} added a new transaction: {entity}",
"{user} updated the transaction '{entity}'": "{user} updated the transaction '{entity}'",
"user_list": "user list",
"user_module" : "Umbrella user management",
"user profile": "User profile",
@@ -455,10 +458,11 @@
"wiki_pages": "wiki pages",
"year": "year",
"You have been added to the new project '{project}', created by {user}:\n\n{body}": "You have been added to the new project '{project}', created by {user}:\n\n{body}",
"You can view/edit this transaction at {base_url}/account/{id}": "Du kannst diese transaktion unter {base_url}/account/{id} ansehen",
"You can view/edit this project at {base_url}/project/{id}/view": "You can view/edit this project at {base_url}/project/{id}/view",
"You can view/edit this task at {base_url}/task/{id}/view": "You can view/edit this task at {base_url}/task/{id}/view",
"You can view/edit this wiki page at {base_url}/wiki/{id}/view": "You can view/edit this wiki page at {base_url}/wiki/{id}/view",
"You have been added to the new project '{project}', created by {user}:\n\n{body}": "You have been added to the new project '{project}', created by {user}:\n\n{body}",
"You may change your notification settings at {base_url}/message/settings": "You may change your notification settings at {base_url}/message/settings .",
"Your token to create a new password" : "Your token to create a new password",
"your_profile": "your profile"