started to implement updates on transactions

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-04-10 09:23:26 +02:00
parent ec3add70c6
commit 90a7c5dd18
21 changed files with 215 additions and 68 deletions

View File

@@ -53,9 +53,10 @@ public class Path {
public static final String STATE = "state";
public static final String STOP = "stop";
public static final String TAGS = "tags";
public static final String TAGGED = "tagged";
public static final String TOKEN = "token";
public static final String TAGS = "tags";
public static final String TAGGED = "tagged";
public static final String TRANSACTION = "transaction";
public static final String TOKEN = "token";
public static final String USER = "user";
public static final String USES = "uses";

View File

@@ -78,6 +78,7 @@ public class Text {
public static final String TASKS = "tasks";
public static final String TIMETRACKING = "timetracking";
public static final String TIME_WITH_ID = "time ({id})";
public static final String TRANSACTION = "transaction";
public static final String TYPE = "type";
public static final String UNIT = "unit";

View File

@@ -5,6 +5,7 @@ import de.srsoftware.tools.Mappable;
import de.srsoftware.umbrella.core.constants.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.HashSet;
@@ -13,8 +14,53 @@ import java.util.Set;
import static java.text.MessageFormat.format;
public record Transaction(long id, long accountId, LocalDateTime date, IdOrString source, IdOrString destination, double amount, String purpose, Set<String> tags) implements Mappable {
public class Transaction implements Mappable {
private long accountId, id;
private LocalDateTime date;
private IdOrString source, destination;
private double amount;
private String purpose;
private Set<String> tags;
public Transaction(long id, long accountId, LocalDateTime date, IdOrString source, IdOrString destination, double amount, String purpose, Set<String> tags){
this.id = id;
this.accountId = accountId;
this.date = date;
this.source = source;
this.destination = destination;
this.amount = amount;
this.purpose = purpose;
this.tags = tags == null ? new HashSet<>() : tags;
}
public long accountId(){
return accountId;
}
public double amount(){
return amount;
}
public LocalDateTime date(){
return date;
}
public Transaction date(LocalDateTime newVal){
date = newVal;
return this;
}
public void date(LocalDate date) {
this.date = this.date.withYear(date.getYear()).withMonth(date.getMonthValue()).withDayOfMonth(date.getDayOfMonth());
}
public IdOrString destination(){
return destination;
}
public long id(){
return id;
}
public static Transaction of(ResultSet rs) throws SQLException {
var accountId = rs.getLong(Field.ACCOUNT);
@@ -25,7 +71,19 @@ public record Transaction(long id, long accountId, LocalDateTime date, IdOrStrin
var amount = rs.getDouble(Field.AMOUNT);
var purpose = rs.getString(Field.DESCRIPTION);
var id = rs.getLong(Field.ID);
return new Transaction(id, accountId, date, source, destination, amount, purpose, new HashSet<>());
return new Transaction(id, accountId, date, source, destination, amount, purpose, null);
}
public String purpose(){
return purpose;
}
public IdOrString source(){
return source;
}
public Set<String> tags(){
return tags;
}
@Override