rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61)
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61) Co-authored-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com> Co-committed-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
This commit was merged in pull request #61.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Allocation, WeekdayAvailability } from "@capakraken/shared";
|
||||
import type { Allocation, WeekdayAvailability } from "@nexus/shared";
|
||||
import { getAvailableHoursForDate } from "./calculator.js";
|
||||
|
||||
export interface AvailabilityConflict {
|
||||
|
||||
@@ -4,8 +4,8 @@ import type {
|
||||
AllocationCalculationResult,
|
||||
DailyBreakdown,
|
||||
WeekdayAvailability,
|
||||
} from "@capakraken/shared";
|
||||
import type { AbsenceTrigger } from "@capakraken/shared";
|
||||
} from "@nexus/shared";
|
||||
import type { AbsenceTrigger } from "@nexus/shared";
|
||||
import { getRecurringHoursForDay } from "./recurrence.js";
|
||||
import { findMatchingRule, applyCostEffect } from "../rules/engine.js";
|
||||
|
||||
@@ -24,10 +24,7 @@ const DOW_KEYS: (keyof WeekdayAvailability)[] = [
|
||||
* Returns the availability hours for a given date.
|
||||
* Returns 0 for days not in the availability map (treated as non-working).
|
||||
*/
|
||||
export function getAvailableHoursForDate(
|
||||
date: Date,
|
||||
availability: WeekdayAvailability,
|
||||
): number {
|
||||
export function getAvailableHoursForDate(date: Date, availability: WeekdayAvailability): number {
|
||||
const key = DOW_KEYS[date.getDay()];
|
||||
if (!key) return 0;
|
||||
return availability[key] ?? 0;
|
||||
@@ -72,10 +69,22 @@ export function countWorkingDays(
|
||||
*
|
||||
* Monetary values always in integer cents.
|
||||
*/
|
||||
export function calculateAllocation(input: AllocationCalculationInput): AllocationCalculationResult {
|
||||
export function calculateAllocation(
|
||||
input: AllocationCalculationInput,
|
||||
): AllocationCalculationResult {
|
||||
const {
|
||||
lcrCents, hoursPerDay, startDate, endDate, availability, includeSaturday,
|
||||
recurrence, vacationDates, absenceDays, calculationRules, orderType, projectId,
|
||||
lcrCents,
|
||||
hoursPerDay,
|
||||
startDate,
|
||||
endDate,
|
||||
availability,
|
||||
includeSaturday,
|
||||
recurrence,
|
||||
vacationDates,
|
||||
absenceDays,
|
||||
calculationRules,
|
||||
orderType,
|
||||
projectId,
|
||||
} = input;
|
||||
|
||||
// When includeSaturday is not explicitly true, zero out saturday availability
|
||||
@@ -158,7 +167,11 @@ export function calculateAllocation(input: AllocationCalculationInput): Allocati
|
||||
if (match) {
|
||||
// Cost effect: how much does the project pay?
|
||||
const normalCostCents = Math.round(absentHours * lcrCents);
|
||||
const absentProjectCost = applyCostEffect(normalCostCents, match.costEffect, match.costReductionPercent);
|
||||
const absentProjectCost = applyCostEffect(
|
||||
normalCostCents,
|
||||
match.costEffect,
|
||||
match.costReductionPercent,
|
||||
);
|
||||
const workedCostCents = Math.round(workedHours * lcrCents);
|
||||
projectCostCents = workedCostCents + absentProjectCost;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DAY_KEYS, type WeekdayAvailability } from "@capakraken/shared";
|
||||
import { DAY_KEYS, type WeekdayAvailability } from "@nexus/shared";
|
||||
|
||||
export interface ChargeabilityAllocation {
|
||||
startDate: Date;
|
||||
@@ -39,13 +39,17 @@ export function computeBookedHours(
|
||||
end: Date,
|
||||
): number {
|
||||
let hours = 0;
|
||||
const startNorm = new Date(start); startNorm.setHours(0, 0, 0, 0);
|
||||
const endNorm = new Date(end); endNorm.setHours(0, 0, 0, 0);
|
||||
const startNorm = new Date(start);
|
||||
startNorm.setHours(0, 0, 0, 0);
|
||||
const endNorm = new Date(end);
|
||||
endNorm.setHours(0, 0, 0, 0);
|
||||
for (const alloc of allocations) {
|
||||
const aStart = new Date(alloc.startDate); aStart.setHours(0, 0, 0, 0);
|
||||
const aEnd = new Date(alloc.endDate); aEnd.setHours(0, 0, 0, 0);
|
||||
const aStart = new Date(alloc.startDate);
|
||||
aStart.setHours(0, 0, 0, 0);
|
||||
const aEnd = new Date(alloc.endDate);
|
||||
aEnd.setHours(0, 0, 0, 0);
|
||||
const overlapStart = aStart > startNorm ? aStart : startNorm;
|
||||
const overlapEnd = aEnd < endNorm ? aEnd : endNorm;
|
||||
const overlapEnd = aEnd < endNorm ? aEnd : endNorm;
|
||||
if (overlapStart > overlapEnd) continue;
|
||||
const cur = new Date(overlapStart);
|
||||
while (cur <= overlapEnd) {
|
||||
@@ -67,9 +71,8 @@ export function computeChargeability(
|
||||
end: Date,
|
||||
): ChargeabilityResult {
|
||||
const availableHours = computeAvailableHours(availability, start, end);
|
||||
const bookedHours = computeBookedHours(availability, allocations, start, end);
|
||||
const chargeability = availableHours > 0
|
||||
? Math.min(100, Math.round((bookedHours / availableHours) * 100))
|
||||
: 0;
|
||||
const bookedHours = computeBookedHours(availability, allocations, start, end);
|
||||
const chargeability =
|
||||
availableHours > 0 ? Math.min(100, Math.round((bookedHours / availableHours) * 100)) : 0;
|
||||
return { availableHours, bookedHours, chargeability };
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { RecurrencePattern } from "@capakraken/shared";
|
||||
import { RecurrenceFrequency } from "@capakraken/shared";
|
||||
import type { RecurrencePattern } from "@nexus/shared";
|
||||
import { RecurrenceFrequency } from "@nexus/shared";
|
||||
|
||||
/**
|
||||
* Returns the ISO week number of a date relative to a base date.
|
||||
|
||||
Reference in New Issue
Block a user