This commit is contained in:
2026-03-31 15:30:12 +02:00
parent 84a044bcb1
commit d3cab642fb
5 changed files with 9 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@@ -23,6 +23,9 @@ public class TallyEntry extends PanacheEntityBase {
@JoinColumn(name = "product_id", nullable = false) @JoinColumn(name = "product_id", nullable = false)
public Product product; public Product product;
@Column(name = "price_cents_at_booking", nullable = false)
public int priceCentsAtBooking;
@Column(name = "month_key", nullable = false, length = 7) @Column(name = "month_key", nullable = false, length = 7)
public String monthKey; public String monthKey;

View File

@@ -171,9 +171,9 @@ public class CompanyAdminResource {
String monthKey = month != null ? month : LocalDateTime.now().format(MONTH_FORMAT); String monthKey = month != null ? month : LocalDateTime.now().format(MONTH_FORMAT);
List<MonthlyTallyDto> tallies = TallyEntry.find( List<MonthlyTallyDto> tallies = TallyEntry.find(
"SELECT t.product.name, t.product.priceCents, COUNT(t), COUNT(t) * t.product.priceCents " + "SELECT t.product.name, t.priceCentsAtBooking, COUNT(t), SUM(t.priceCentsAtBooking) " +
"FROM TallyEntry t WHERE t.employee.id = ?1 AND t.monthKey = ?2 " + "FROM TallyEntry t WHERE t.employee.id = ?1 AND t.monthKey = ?2 " +
"GROUP BY t.product.id, t.product.name, t.product.priceCents", "GROUP BY t.product.id, t.product.name, t.priceCentsAtBooking",
employeeId, monthKey) employeeId, monthKey)
.project(MonthlyTallyDto.class) .project(MonthlyTallyDto.class)
.list(); .list();

View File

@@ -57,6 +57,7 @@ public class PublicResource {
TallyEntry entry = new TallyEntry(); TallyEntry entry = new TallyEntry();
entry.employee = employee; entry.employee = employee;
entry.product = product; entry.product = product;
entry.priceCentsAtBooking = product.priceCents;
entry.persist(); entry.persist();
return Response.status(Response.Status.CREATED).build(); return Response.status(Response.Status.CREATED).build();
@@ -83,9 +84,9 @@ public class PublicResource {
String monthKey = month != null ? month : LocalDateTime.now().format(MONTH_FORMAT); String monthKey = month != null ? month : LocalDateTime.now().format(MONTH_FORMAT);
return TallyEntry.find( return TallyEntry.find(
"SELECT t.product.name, t.product.priceCents, COUNT(t), COUNT(t) * t.product.priceCents " + "SELECT t.product.name, t.priceCentsAtBooking, COUNT(t), SUM(t.priceCentsAtBooking) " +
"FROM TallyEntry t WHERE t.employee.id = ?1 AND t.monthKey = ?2 " + "FROM TallyEntry t WHERE t.employee.id = ?1 AND t.monthKey = ?2 " +
"GROUP BY t.product.id, t.product.name, t.product.priceCents", "GROUP BY t.product.id, t.product.name, t.priceCentsAtBooking",
employeeId, monthKey) employeeId, monthKey)
.project(MonthlyTallyDto.class) .project(MonthlyTallyDto.class)
.list(); .list();

View File

@@ -0,0 +1 @@
ALTER TABLE tally_entry ADD COLUMN price_cents_at_booking INT NOT NULL DEFAULT 0;