feat(scenario): scope baseline reads to planning and cost audiences

This commit is contained in:
2026-03-30 09:40:07 +02:00
parent 3aac946443
commit 806c028974
2 changed files with 140 additions and 2 deletions
+5 -2
View File
@@ -1,8 +1,9 @@
import { calculateAllocation } from "@capakraken/engine/allocation";
import { PermissionKey } from "@capakraken/shared";
import type { WeekdayAvailability } from "@capakraken/shared";
import { z } from "zod";
import { TRPCError } from "@trpc/server";
import { createTRPCRouter, controllerProcedure, protectedProcedure } from "../trpc.js";
import { createTRPCRouter, controllerProcedure, planningReadProcedure, requirePermission } from "../trpc.js";
import { createAuditEntry } from "../lib/audit.js";
import {
calculateEffectiveAvailableHours,
@@ -41,9 +42,11 @@ export const scenarioRouter = createTRPCRouter({
/**
* Returns current allocations/costs for a project — the baseline for comparison.
*/
getProjectBaseline: protectedProcedure
getProjectBaseline: planningReadProcedure
.input(z.object({ projectId: z.string() }))
.query(async ({ ctx, input }) => {
requirePermission(ctx, PermissionKey.VIEW_COSTS);
const project = await ctx.db.project.findUnique({
where: { id: input.projectId },
select: {