diff --git a/src/main/java/io/ventureplatform/util/InvestmentRollup.java b/src/main/java/io/ventureplatform/util/InvestmentRollup.java new file mode 100644 index 0000000..57615df --- /dev/null +++ b/src/main/java/io/ventureplatform/util/InvestmentRollup.java @@ -0,0 +1,100 @@ +package io.ventureplatform.util; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Aggregates investment data across portfolio companies + * for dashboard rollups. + * + *
Used by reporting endpoints to compute category-level
+ * totals and rankings without round-tripping to the database
+ * for every aggregation.
+ */
+public final class InvestmentRollup {
+
+ private InvestmentRollup() {
+ // utility class
+ }
+
+ /**
+ * Typed representation of a company investment entry.
+ *
+ * @param category investment category
+ * @param amount investment amount
+ * @param name company name
+ */
+ public record CompanyInvestment(
+ String category, long amount, String name) { }
+
+ /**
+ * Parameterized SQL filter with bind values.
+ *
+ * @param clause SQL clause with positional placeholders
+ * @param parameters bind values for the placeholders
+ */
+ public record CategoryFilter(
+ String clause, List Returns {@code 1=0} with an empty parameter list
+ * when the input is empty.
+ */
+ public static CategoryFilter buildCategoryFilter(
+ final List