#10 Create period overview

WIP commit
This commit is contained in:
2021-03-04 18:12:18 +01:00
parent 51d491c5d1
commit 5a13429e9b
18 changed files with 543 additions and 4 deletions

View File

@@ -0,0 +1,130 @@
package de.financer.dto;
import de.financer.model.PeriodType;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import java.time.LocalDate;
public class PeriodOverviewDto {
private Long periodId;
private PeriodType periodType;
private LocalDate periodStart;
private LocalDate periodEnd;
private Long incomeSum;
private Long expenseSum;
private Long liabilitySum;
private Long total;
private Long assetsSum;
private Long transactionCount;
public PeriodOverviewDto() {
}
public PeriodOverviewDto(Long periodId,
String periodType,
LocalDate periodStart,
LocalDate periodEnd,
Long incomeSum,
Long expenseSum,
Long liabilitySum,
Long total,
Long assetsSum,
Long transactionCount) {
this.periodId = periodId;
this.periodType = PeriodType.valueOf(periodType);
this.periodStart = periodStart;
this.periodEnd = periodEnd;
this.incomeSum = incomeSum;
this.expenseSum = expenseSum;
this.liabilitySum = liabilitySum;
this.total = total;
this.assetsSum = assetsSum;
this.transactionCount = transactionCount;
}
public Long getPeriodId() {
return periodId;
}
public void setPeriodId(Long periodId) {
this.periodId = periodId;
}
public PeriodType getPeriodType() {
return periodType;
}
public void setPeriodType(PeriodType periodType) {
this.periodType = periodType;
}
public LocalDate getPeriodStart() {
return periodStart;
}
public void setPeriodStart(LocalDate periodStart) {
this.periodStart = periodStart;
}
public LocalDate getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(LocalDate periodEnd) {
this.periodEnd = periodEnd;
}
public Long getIncomeSum() {
return incomeSum;
}
public void setIncomeSum(Long incomeSum) {
this.incomeSum = incomeSum;
}
public Long getExpenseSum() {
return expenseSum;
}
public void setExpenseSum(Long expenseSum) {
this.expenseSum = expenseSum;
}
public Long getLiabilitySum() {
return liabilitySum;
}
public void setLiabilitySum(Long liabilitySum) {
this.liabilitySum = liabilitySum;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
public Long getAssetsSum() {
return assetsSum;
}
public void setAssetsSum(Long assetsSum) {
this.assetsSum = assetsSum;
}
public Long getTransactionCount() {
return transactionCount;
}
public void setTransactionCount(Long transactionCount) {
this.transactionCount = transactionCount;
}
}

View File

@@ -1,9 +1,29 @@
package de.financer.model;
import de.financer.dto.PeriodOverviewDto;
import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Entity
// I don't like having that here, but it needs to be annotated on some @Entity
// and this entity is the best match
@SqlResultSetMapping(name = "PeriodOverviewResult",
classes = {
@ConstructorResult(targetClass = PeriodOverviewDto.class,
columns = {
@ColumnResult(name = "PERIOD_ID", type = Long.class),
@ColumnResult(name = "PERIOD_TYPE", type = String.class),
@ColumnResult(name = "PERIOD_START", type = LocalDate.class),
@ColumnResult(name = "PERIOD_END", type = LocalDate.class),
@ColumnResult(name = "INCOME_SUM", type = Long.class),
@ColumnResult(name = "EXPENSE_SUM", type = Long.class),
@ColumnResult(name = "LIABILITY_SUM", type = Long.class),
@ColumnResult(name = "TOTAL", type = Long.class),
@ColumnResult(name = "ASSETS_SUM", type = Long.class),
@ColumnResult(name = "TRANSACTION_COUNT", type = Long.class)})
})
public class Period {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)