Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe57749d9c | |||
| d3f9ca2c5d | |||
| fe18cb8dc2 | |||
| 20f47055f6 | |||
| c6caf7aacc | |||
| cc3a3a23a2 | |||
| cfd5362b1d | |||
| ca24ada1fd | |||
| 2adba956de | |||
| 3a2ab75b15 | |||
| 719558e8ee | |||
| 80311c8493 | |||
| 713edd3638 |
@@ -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,14 +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 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 static de.srsoftware.umbrella.messagebus.events.Event.EventType.UPDATE;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
@@ -26,13 +22,12 @@ 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;
|
||||
import java.util.*;
|
||||
|
||||
import de.srsoftware.umbrella.messagebus.events.Event;
|
||||
import de.srsoftware.umbrella.messagebus.events.TransactionEvent;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -58,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);
|
||||
@@ -131,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);
|
||||
@@ -143,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);
|
||||
@@ -182,7 +185,7 @@ 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));
|
||||
}
|
||||
|
||||
@@ -221,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)));
|
||||
@@ -230,7 +234,7 @@ public class AccountingModule extends BaseHandler implements AccountingService {
|
||||
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));
|
||||
var patched = accountDb.save(transaction);
|
||||
messageBus().dispatch(new TransactionEvent(user,patched,UPDATE));
|
||||
messageBus().dispatch(new TransactionEvent(user,patched,oldData));
|
||||
return sendContent(ex,patched);
|
||||
}
|
||||
|
||||
@@ -332,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,11 +7,10 @@ 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;
|
||||
import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.UPDATE;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.tools.jdbc.Condition;
|
||||
@@ -21,8 +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.messagebus.events.TransactionEvent;
|
||||
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.ZoneOffset;
|
||||
@@ -121,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 {
|
||||
@@ -135,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 {
|
||||
@@ -299,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);
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
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 de.srsoftware.umbrella.core.model.UnTranslatable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.accountingService;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import java.util.Map;
|
||||
|
||||
public class TransactionEvent extends Event<Transaction> {
|
||||
private Collection<UmbrellaUser> audience;
|
||||
@@ -22,6 +22,11 @@ public class TransactionEvent extends Event<Transaction> {
|
||||
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();
|
||||
@@ -30,14 +35,41 @@ public class TransactionEvent extends Event<Transaction> {
|
||||
|
||||
@Override
|
||||
public Translatable describe() {
|
||||
return new UnTranslatable(payload().purpose());
|
||||
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_created_entity",initiator().name(), Text.TRANSACTION);
|
||||
case UPDATE -> t("user_updated_entity",initiator().name(), Text.TRANSACTION);
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
/* © 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;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Util.mapValues;
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -57,13 +57,9 @@
|
||||
window.setTimeout(scrollToBottom,100);
|
||||
}
|
||||
|
||||
function handleEvent(evt,method){
|
||||
let event_data = JSON.parse(evt.data);
|
||||
console.log({method, event_data});
|
||||
}
|
||||
|
||||
function handleDeleteEvent(evt){
|
||||
handleEvent(evt,'delete');
|
||||
const event_data = JSON.parse(evt.data);
|
||||
transactions = transactions.filter(t => t.id != event_data.transaction.id);
|
||||
}
|
||||
|
||||
function handleUpdateEvent(evt){
|
||||
@@ -139,6 +135,7 @@
|
||||
<th>{t('other party')}</th>
|
||||
<th>{t('purpose')}</th>
|
||||
<th>{t('tags')}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -160,7 +157,7 @@
|
||||
<br/>
|
||||
{sums[0].toFixed(2)} {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}
|
||||
|
||||
@@ -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} />
|
||||
|
||||
@@ -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.*;
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user