working on update of transactions

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-04-10 09:30:41 +02:00
parent 90a7c5dd18
commit 0c6e5850d2
4 changed files with 33 additions and 12 deletions

View File

@@ -21,6 +21,7 @@ public class Transaction implements Mappable {
private double amount;
private String purpose;
private Set<String> tags;
private HashSet<String> dirtyFields = new HashSet<>();
public Transaction(long id, long accountId, LocalDateTime date, IdOrString source, IdOrString destination, double amount, String purpose, Set<String> tags){
this.id = id;
@@ -41,17 +42,23 @@ public class Transaction implements Mappable {
return amount;
}
public Transaction clearDirtyState(){
dirtyFields.clear();
return this;
}
public LocalDateTime date(){
return date;
}
public Transaction date(LocalDateTime newVal){
date = newVal;
dirtyFields.add(Field.DATE);
return this;
}
public void date(LocalDate date) {
this.date = this.date.withYear(date.getYear()).withMonth(date.getMonthValue()).withDayOfMonth(date.getDayOfMonth());
public Transaction date(LocalDate date) {
return date(this.date.withYear(date.getYear()).withMonth(date.getMonthValue()).withDayOfMonth(date.getDayOfMonth()));
}
public IdOrString destination(){
@@ -62,6 +69,10 @@ public class Transaction implements Mappable {
return id;
}
public boolean isDirty(){
return !dirtyFields.isEmpty();
}
public static Transaction of(ResultSet rs) throws SQLException {
var accountId = rs.getLong(Field.ACCOUNT);
var timestamp = rs.getLong(Field.TIMESTAMP);
@@ -78,6 +89,12 @@ public class Transaction implements Mappable {
return purpose;
}
public Transaction purpose(String newVal){
purpose = newVal;
dirtyFields.add(Field.PURPOSE);
return this;
}
public IdOrString source(){
return source;
}