feat: calculation rules engine for decoupled cost attribution and chargeability
Introduces an admin-configurable rules engine that determines per-day cost attribution (CHARGE/ZERO/REDUCE) and chargeability reporting (COUNT/SKIP) for absence types (sick, vacation, public holiday). Includes shared types, Zod schemas, Prisma model, rule matching with specificity scoring, default rules, calculator integration, CRUD API router, seed data, chargeability report integration, and admin UI. 283/283 engine tests, 209/209 API tests, 0 TS errors. Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -293,6 +293,7 @@ async function main() {
|
||||
await prisma.resourceRole.deleteMany({});
|
||||
await prisma.vacation.deleteMany({});
|
||||
await prisma.vacationEntitlement.deleteMany({});
|
||||
await prisma.calculationRule.deleteMany({});
|
||||
await prisma.project.deleteMany({});
|
||||
await prisma.resource.deleteMany({});
|
||||
await prisma.role.deleteMany({});
|
||||
@@ -1215,6 +1216,40 @@ async function main() {
|
||||
}
|
||||
console.warn(`Vacations: ${vacationCount} created`);
|
||||
|
||||
// ── Calculation Rules (default set) ──────────────────────────────────────────
|
||||
await prisma.calculationRule.createMany({
|
||||
data: [
|
||||
{
|
||||
name: "Urlaub — Person chargeable, Projekt nicht belastet",
|
||||
description: "Vacation days count toward chargeability but are not charged to the project.",
|
||||
triggerType: "VACATION",
|
||||
costEffect: "ZERO",
|
||||
chargeabilityEffect: "COUNT",
|
||||
priority: 0,
|
||||
isActive: true,
|
||||
},
|
||||
{
|
||||
name: "Krankheit — Person chargeable, Projekt nicht belastet",
|
||||
description: "Sick days count toward chargeability but are not charged to the project.",
|
||||
triggerType: "SICK",
|
||||
costEffect: "ZERO",
|
||||
chargeabilityEffect: "COUNT",
|
||||
priority: 0,
|
||||
isActive: true,
|
||||
},
|
||||
{
|
||||
name: "Feiertag — kein Effekt",
|
||||
description: "Public holidays are neither chargeable nor charged to projects.",
|
||||
triggerType: "PUBLIC_HOLIDAY",
|
||||
costEffect: "ZERO",
|
||||
chargeabilityEffect: "SKIP",
|
||||
priority: 0,
|
||||
isActive: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
console.warn("Calculation rules: 3 default rules created");
|
||||
|
||||
console.warn("Seed complete!");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user