feat: dashboard overhaul, chargeability reports, dispo import enhancements, UI polish
Dashboard: expanded chargeability widget, resource/project table widgets with sorting and filters, stat cards with formatMoney integration. Chargeability: new report client with filtering, chargeability-bookings use case, updated dashboard overview logic. Dispo import: TBD project handling, parse-dispo-matrix improvements, stage-dispo-projects resource value scores, new tests. Estimates: CommercialTermsEditor component, commercial-terms engine module, expanded estimate schemas and types. UI: AppShell navigation updates, timeline filter/toolbar enhancements, role management improvements, signin page redesign, Tailwind/globals polish, SystemSettings SMTP section, anonymization support. Tests: new router tests (anonymization, chargeability, effort-rule, entitlement, estimate, experience-multiplier, notification, resource, staffing, vacation). Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -10,10 +10,11 @@ import {
|
||||
type AssignmentSlice,
|
||||
} from "@planarchy/engine";
|
||||
import type { SpainScheduleRule } from "@planarchy/shared";
|
||||
import { listAssignmentBookings } from "@planarchy/application";
|
||||
import { isChargeabilityActualBooking, listAssignmentBookings } from "@planarchy/application";
|
||||
import { VacationStatus } from "@planarchy/db";
|
||||
import { z } from "zod";
|
||||
import { createTRPCRouter, controllerProcedure } from "../trpc.js";
|
||||
import { anonymizeResources, getAnonymizationDirectory } from "../lib/anonymization.js";
|
||||
|
||||
export const chargeabilityReportRouter = createTRPCRouter({
|
||||
getReport: controllerProcedure
|
||||
@@ -24,10 +25,11 @@ export const chargeabilityReportRouter = createTRPCRouter({
|
||||
orgUnitId: z.string().optional(),
|
||||
managementLevelGroupId: z.string().optional(),
|
||||
countryId: z.string().optional(),
|
||||
includeProposed: z.boolean().default(false),
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
const { startMonth, endMonth } = input;
|
||||
const { startMonth, endMonth, includeProposed } = input;
|
||||
|
||||
// Parse month range
|
||||
const [startYear, startMo] = startMonth.split("-").map(Number) as [number, number];
|
||||
@@ -100,7 +102,8 @@ export const chargeabilityReportRouter = createTRPCRouter({
|
||||
|
||||
// Normalize bookings to a common shape
|
||||
const assignments = allBookings
|
||||
.filter((b) => b.resourceId !== null)
|
||||
.filter((booking) => booking.resourceId !== null)
|
||||
.filter((booking) => isChargeabilityActualBooking(booking, includeProposed))
|
||||
.map((b) => ({
|
||||
resourceId: b.resourceId!,
|
||||
startDate: b.startDate,
|
||||
@@ -171,8 +174,6 @@ export const chargeabilityReportRouter = createTRPCRouter({
|
||||
// Build assignment slices for this month
|
||||
const slices: AssignmentSlice[] = [];
|
||||
for (const a of resourceAssignments) {
|
||||
// Skip DRAFT projects
|
||||
if (a.project.status === "DRAFT" || a.project.status === "CANCELLED") continue;
|
||||
const workingDays = countWorkingDaysInOverlap(monthStart, monthEnd, a.startDate, a.endDate);
|
||||
if (workingDays <= 0) continue;
|
||||
|
||||
@@ -236,9 +237,11 @@ export const chargeabilityReportRouter = createTRPCRouter({
|
||||
};
|
||||
});
|
||||
|
||||
const directory = await getAnonymizationDirectory(ctx.db);
|
||||
|
||||
return {
|
||||
monthKeys,
|
||||
resources: resourceRows,
|
||||
resources: anonymizeResources(resourceRows, directory),
|
||||
groupTotals,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
getDashboardPeakTimes,
|
||||
getDashboardTopValueResources,
|
||||
} from "@planarchy/application";
|
||||
import { anonymizeResources, getAnonymizationDirectory } from "../lib/anonymization.js";
|
||||
|
||||
export const dashboardRouter = createTRPCRouter({
|
||||
getOverview: protectedProcedure.query(({ ctx }) => getDashboardOverview(ctx.db)),
|
||||
@@ -31,13 +32,17 @@ export const dashboardRouter = createTRPCRouter({
|
||||
|
||||
getTopValueResources: protectedProcedure
|
||||
.input(z.object({ limit: z.number().int().min(1).max(50).default(10) }))
|
||||
.query(({ ctx, input }) =>
|
||||
getDashboardTopValueResources(ctx.db, {
|
||||
limit: input.limit,
|
||||
userRole:
|
||||
(ctx.session.user as { role?: string } | undefined)?.role ?? "USER",
|
||||
}),
|
||||
),
|
||||
.query(async ({ ctx, input }) => {
|
||||
const [resources, directory] = await Promise.all([
|
||||
getDashboardTopValueResources(ctx.db, {
|
||||
limit: input.limit,
|
||||
userRole:
|
||||
(ctx.session.user as { role?: string } | undefined)?.role ?? "USER",
|
||||
}),
|
||||
getAnonymizationDirectory(ctx.db),
|
||||
]);
|
||||
return anonymizeResources(resources, directory);
|
||||
}),
|
||||
|
||||
getDemand: protectedProcedure
|
||||
.input(
|
||||
@@ -58,14 +63,29 @@ export const dashboardRouter = createTRPCRouter({
|
||||
getChargeabilityOverview: controllerProcedure
|
||||
.input(
|
||||
z.object({
|
||||
includeProposed: z.boolean().default(false),
|
||||
topN: z.number().int().min(1).max(50).default(10),
|
||||
watchlistThreshold: z.number().default(15),
|
||||
countryIds: z.array(z.string()).optional(),
|
||||
departed: z.boolean().optional(),
|
||||
}),
|
||||
)
|
||||
.query(({ ctx, input }) =>
|
||||
getDashboardChargeabilityOverview(ctx.db, {
|
||||
topN: input.topN,
|
||||
watchlistThreshold: input.watchlistThreshold,
|
||||
}),
|
||||
),
|
||||
.query(async ({ ctx, input }) => {
|
||||
const [overview, directory] = await Promise.all([
|
||||
getDashboardChargeabilityOverview(ctx.db, {
|
||||
includeProposed: input.includeProposed,
|
||||
topN: input.topN,
|
||||
watchlistThreshold: input.watchlistThreshold,
|
||||
...(input.countryIds !== undefined ? { countryIds: input.countryIds } : {}),
|
||||
...(input.departed !== undefined ? { departed: input.departed } : {}),
|
||||
}),
|
||||
getAnonymizationDirectory(ctx.db),
|
||||
]);
|
||||
|
||||
return {
|
||||
...overview,
|
||||
top: anonymizeResources(overview.top, directory),
|
||||
watchlist: anonymizeResources(overview.watchlist, directory),
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -38,6 +38,10 @@ export const settingsRouter = createTRPCRouter({
|
||||
smtpFrom: settings?.smtpFrom ?? null,
|
||||
smtpTls: settings?.smtpTls ?? true,
|
||||
hasSmtpPassword: !!settings?.smtpPassword,
|
||||
// Global anonymization
|
||||
anonymizationEnabled: settings?.anonymizationEnabled ?? false,
|
||||
anonymizationDomain: settings?.anonymizationDomain ?? "superhartmut.de",
|
||||
anonymizationMode: settings?.anonymizationMode ?? "global",
|
||||
// Vacation defaults
|
||||
vacationDefaultDays: settings?.vacationDefaultDays ?? 28,
|
||||
};
|
||||
@@ -75,6 +79,11 @@ export const settingsRouter = createTRPCRouter({
|
||||
smtpPassword: z.string().optional(),
|
||||
smtpFrom: z.string().email().optional().or(z.literal("")),
|
||||
smtpTls: z.boolean().optional(),
|
||||
// Global anonymization
|
||||
anonymizationEnabled: z.boolean().optional(),
|
||||
anonymizationDomain: z.string().trim().min(1).optional(),
|
||||
anonymizationSeed: z.string().trim().min(1).optional().or(z.literal("")),
|
||||
anonymizationMode: z.enum(["global"]).optional(),
|
||||
// Vacation
|
||||
vacationDefaultDays: z.number().int().min(0).max(365).optional(),
|
||||
}),
|
||||
@@ -107,6 +116,17 @@ export const settingsRouter = createTRPCRouter({
|
||||
if (input.smtpPassword !== undefined) data.smtpPassword = input.smtpPassword || null;
|
||||
if (input.smtpFrom !== undefined) data.smtpFrom = input.smtpFrom || null;
|
||||
if (input.smtpTls !== undefined) data.smtpTls = input.smtpTls;
|
||||
// Global anonymization
|
||||
if (input.anonymizationEnabled !== undefined) data.anonymizationEnabled = input.anonymizationEnabled;
|
||||
if (input.anonymizationDomain !== undefined) data.anonymizationDomain = input.anonymizationDomain || "superhartmut.de";
|
||||
if (input.anonymizationSeed !== undefined) {
|
||||
data.anonymizationSeed = input.anonymizationSeed || null;
|
||||
data.anonymizationAliases = null;
|
||||
}
|
||||
if (input.anonymizationMode !== undefined) {
|
||||
data.anonymizationMode = input.anonymizationMode;
|
||||
data.anonymizationAliases = null;
|
||||
}
|
||||
// Vacation
|
||||
if (input.vacationDefaultDays !== undefined) data.vacationDefaultDays = input.vacationDefaultDays;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user