diff --git a/AquanticoLogo_Horizontal.png b/AquanticoLogo_Horizontal.png new file mode 100644 index 0000000..deedac1 Binary files /dev/null and b/AquanticoLogo_Horizontal.png differ diff --git a/backend/src/main/java/de/strichliste/entity/TallyEntry.java b/backend/src/main/java/de/strichliste/entity/TallyEntry.java index a853a80..d89d2a5 100644 --- a/backend/src/main/java/de/strichliste/entity/TallyEntry.java +++ b/backend/src/main/java/de/strichliste/entity/TallyEntry.java @@ -23,6 +23,9 @@ public class TallyEntry extends PanacheEntityBase { @JoinColumn(name = "product_id", nullable = false) public Product product; + @Column(name = "price_cents_at_booking", nullable = false) + public int priceCentsAtBooking; + @Column(name = "month_key", nullable = false, length = 7) public String monthKey; diff --git a/backend/src/main/java/de/strichliste/resource/CompanyAdminResource.java b/backend/src/main/java/de/strichliste/resource/CompanyAdminResource.java index 14666db..1244b1a 100644 --- a/backend/src/main/java/de/strichliste/resource/CompanyAdminResource.java +++ b/backend/src/main/java/de/strichliste/resource/CompanyAdminResource.java @@ -171,9 +171,9 @@ public class CompanyAdminResource { String monthKey = month != null ? month : LocalDateTime.now().format(MONTH_FORMAT); List 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 " + - "GROUP BY t.product.id, t.product.name, t.product.priceCents", + "GROUP BY t.product.id, t.product.name, t.priceCentsAtBooking", employeeId, monthKey) .project(MonthlyTallyDto.class) .list(); diff --git a/backend/src/main/java/de/strichliste/resource/PublicResource.java b/backend/src/main/java/de/strichliste/resource/PublicResource.java index a337f85..2ec9e4d 100644 --- a/backend/src/main/java/de/strichliste/resource/PublicResource.java +++ b/backend/src/main/java/de/strichliste/resource/PublicResource.java @@ -57,6 +57,7 @@ public class PublicResource { TallyEntry entry = new TallyEntry(); entry.employee = employee; entry.product = product; + entry.priceCentsAtBooking = product.priceCents; entry.persist(); return Response.status(Response.Status.CREATED).build(); @@ -83,9 +84,9 @@ public class PublicResource { String monthKey = month != null ? month : LocalDateTime.now().format(MONTH_FORMAT); 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 " + - "GROUP BY t.product.id, t.product.name, t.product.priceCents", + "GROUP BY t.product.id, t.product.name, t.priceCentsAtBooking", employeeId, monthKey) .project(MonthlyTallyDto.class) .list(); diff --git a/backend/src/main/resources/db/migration/V4__tally_price_at_booking.sql b/backend/src/main/resources/db/migration/V4__tally_price_at_booking.sql new file mode 100644 index 0000000..fc0c3a9 --- /dev/null +++ b/backend/src/main/resources/db/migration/V4__tally_price_at_booking.sql @@ -0,0 +1 @@ +ALTER TABLE tally_entry ADD COLUMN price_cents_at_booking INT NOT NULL DEFAULT 0;