refactor(planning): remove the unused remaining-balance mirror

The summary and details already read the displayed plan's remaining
balances, so the writable mirror, its legacy conversion and the VacDay
classification/reason fields it alone populated are removed.

Refs #274

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-10-17 11:05:51 +02:00
1 parent 40a11c245a
commit 7fc2b33587
4 files changed
+5 -45

No files matched your search

@@ -474,7 +474,7 @@ describe('CalendarYear planning outcome boundary', () => {
fixture.detectChanges(); fixture.detectChanges();
const before = { const before = {
balances: structuredClone(input.vacationNumberSignal()), balances: structuredClone(input.vacationNumberSignal()),
remaining: structuredClone(input.remainingVacationDaysSignal()), displayed: structuredClone(input.displayedPlanSignal()),
declarations: structuredClone(input.declaredDaysSignal()), declarations: structuredClone(input.declaredDaysSignal()),
rules: structuredClone(rules.rules), rules: structuredClone(rules.rules),
}; };
@@ -508,7 +508,7 @@ describe('CalendarYear planning outcome boundary', () => {
expect(dialog.textContent?.includes('Partial plan')).toBe(partial); expect(dialog.textContent?.includes('Partial plan')).toBe(partial);
expect(input.planningOutcomeSignal()).toBe(outcome); expect(input.planningOutcomeSignal()).toBe(outcome);
expect(input.vacationNumberSignal()).toEqual(before.balances); expect(input.vacationNumberSignal()).toEqual(before.balances);
expect(input.remainingVacationDaysSignal()).toEqual(before.remaining); expect(input.displayedPlanSignal()).toEqual(before.displayed);
expect(input.declaredDaysSignal()).toEqual(before.declarations); expect(input.declaredDaysSignal()).toEqual(before.declarations);
expect(rules.rules).toEqual(before.rules); expect(rules.rules).toEqual(before.rules);
expect(calendar.createPlanningCalculation).toHaveBeenCalledOnce(); expect(calendar.createPlanningCalculation).toHaveBeenCalledOnce();
@@ -2164,19 +2164,11 @@ describe('CalendarYear planning outcome boundary', () => {
], ],
}).compileComponents(); }).compileComponents();
const userInput = TestBed.inject(UserInputService); const userInput = TestBed.inject(UserInputService);
userInput.remainingVacationDaysSignal.set([
{
id: 'stale',
type: SelectableDayType.CP,
numberOfDays: 1,
expiryDate: new Date('2025-01-01'),
},
]);
const fixture: ComponentFixture<CalendarYear> = TestBed.createComponent(CalendarYear); const fixture: ComponentFixture<CalendarYear> = TestBed.createComponent(CalendarYear);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
expect(userInput.remainingVacationDaysSignal()).toEqual([]); expect(userInput.displayedPlanSignal()).toBeUndefined();
}); });
it('keeps and summarizes a returned result', async () => { it('keeps and summarizes a returned result', async () => {
@@ -2189,13 +2181,12 @@ describe('CalendarYear planning outcome boundary', () => {
], ],
}).compileComponents(); }).compileComponents();
const userInput = TestBed.inject(UserInputService); const userInput = TestBed.inject(UserInputService);
userInput.remainingVacationDaysSignal.set([]);
const fixture = TestBed.createComponent(CalendarYear); const fixture = TestBed.createComponent(CalendarYear);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
await new Promise<void>((resolve) => setTimeout(resolve, 0)); await new Promise<void>((resolve) => setTimeout(resolve, 0));
fixture.detectChanges(); fixture.detectChanges();
expect(userInput.remainingVacationDaysSignal()).toEqual([]); expect(userInput.displayedPlanSignal()?.remainingBalances).toEqual(plan.remainingBalances);
const summaryValues = Array.from( const summaryValues = Array.from(
fixture.nativeElement.querySelectorAll('.plan-summary dd') as NodeListOf<HTMLElement>, fixture.nativeElement.querySelectorAll('.plan-summary dd') as NodeListOf<HTMLElement>,
).map((element) => element.textContent?.trim()); ).map((element) => element.textContent?.trim());
@@ -2969,14 +2960,6 @@ describe('CalendarYear planning outcome boundary', () => {
], ],
}).compileComponents(); }).compileComponents();
const userInput = TestBed.inject(UserInputService); const userInput = TestBed.inject(UserInputService);
userInput.remainingVacationDaysSignal.set([
{
id: 'stale',
type: SelectableDayType.CP,
numberOfDays: 1,
expiryDate: new Date('2025-01-01'),
},
]);
const fixture = TestBed.createComponent(CalendarYear); const fixture = TestBed.createComponent(CalendarYear);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -2988,6 +2971,6 @@ describe('CalendarYear planning outcome boundary', () => {
if (outcome?.kind === 'PlanningIncomplete') if (outcome?.kind === 'PlanningIncomplete')
expect(outcome.reasons[0].code).toBe('planner-error'); expect(outcome.reasons[0].code).toBe('planner-error');
expect(fixture.componentInstance['isLoading']()).toBe(false); expect(fixture.componentInstance['isLoading']()).toBe(false);
expect(userInput.remainingVacationDaysSignal()).toEqual([]); expect(userInput.displayedPlanSignal()).toBeUndefined();
}); });
}); });
@@ -37,8 +37,6 @@ import {
CalendarService, CalendarService,
calendarProjectionHorizon, calendarProjectionHorizon,
SelectedDates, SelectedDates,
SelectableDayType,
VacDay,
} from '../../services/calendar-service'; } from '../../services/calendar-service';
import { TranslationService } from '../../services/translation-service'; import { TranslationService } from '../../services/translation-service';
import { UserInputService } from '../../services/user-input-service'; import { UserInputService } from '../../services/user-input-service';
@@ -50,7 +48,6 @@ import {
LeaveType, LeaveType,
DeclaredNonWorkingDay, DeclaredNonWorkingDay,
PlanExplanation, PlanExplanation,
PlanOutcome,
PlanningCalculationContext, PlanningCalculationContext,
PlanningExplanation, PlanningExplanation,
PlanningObjective, PlanningObjective,
@@ -467,7 +464,6 @@ export class CalendarYear {
this.planDetailsOpen.set(false); this.planDetailsOpen.set(false);
this.clearCounterfactual(); this.clearCounterfactual();
this.selectedDates.set(this.calendarService.getSelectedDatesForHorizon(horizon)); this.selectedDates.set(this.calendarService.getSelectedDatesForHorizon(horizon));
this.userInput.remainingVacationDaysSignal.set([]);
} }
private loadArtifacts(calculation: PlanningCalculationContext): void { private loadArtifacts(calculation: PlanningCalculationContext): void {
@@ -517,13 +513,11 @@ export class CalendarYear {
if (plan) { if (plan) {
this.planningHorizon.set(plan.horizon); this.planningHorizon.set(plan.horizon);
this.selectedDates.set(this.calendarService.selectedDatesForPlan(plan)); this.selectedDates.set(this.calendarService.selectedDatesForPlan(plan));
this.userInput.remainingVacationDaysSignal.set(this.toLegacyBalances(plan));
return; return;
} }
this.selectedDates.set( this.selectedDates.set(
this.calendarService.getSelectedDatesForHorizon(this.planningHorizon()!), this.calendarService.getSelectedDatesForHorizon(this.planningHorizon()!),
); );
this.userInput.remainingVacationDaysSignal.set([]);
} }
protected formatStatistic(value: number | null): string { protected formatStatistic(value: number | null): string {
@@ -1078,16 +1072,4 @@ export class CalendarYear {
if (stage === 'dates') return 98; if (stage === 'dates') return 98;
return this.loadingProgress(); return this.loadingProgress();
} }
private toLegacyBalances(plan: PlanOutcome): VacDay[] {
return plan.remainingBalances.map((balance) => ({
id: balance.id,
type: balance.type as SelectableDayType,
numberOfDays: balance.quantity,
availableDate: new Date(`${balance.availableFrom}T00:00:00`),
expiryDate: new Date(`${balance.expiryDate}T00:00:00`),
classification: balance.classification,
reason: balance.reason,
}));
}
} }
-4
View File
@@ -10,9 +10,7 @@ import {
planLeave as planLeaveOperation, planLeave as planLeaveOperation,
LeaveType, LeaveType,
PlanOutcome, PlanOutcome,
PlanningReason,
PlanningStateSnapshot, PlanningStateSnapshot,
RemainingClassification,
} from './leave-planner.service'; } from './leave-planner.service';
import { addPlanningDays, addPlanningYears, planningDateInParis } from './planning-date'; import { addPlanningDays, addPlanningYears, planningDateInParis } from './planning-date';
@@ -255,8 +253,6 @@ export type VacDay = {
/** Legacy balances omit this value; the planner then uses the horizon start. */ /** Legacy balances omit this value; the planner then uses the horizon start. */
availableDate?: Date; availableDate?: Date;
expiryDate: Date; expiryDate: Date;
classification?: RemainingClassification;
reason?: PlanningReason;
}; };
export type Week = (Date | null)[]; export type Week = (Date | null)[];
-1
View File
@@ -161,7 +161,6 @@ export class UserInputService {
readonly vacationNumberSignal = signal<VacDay[]>( readonly vacationNumberSignal = signal<VacDay[]>(
this.getSavedValues() ?? this.getInitialValues(), this.getSavedValues() ?? this.getInitialValues(),
); );
readonly remainingVacationDaysSignal = signal<VacDay[]>([]);
readonly planningOutcomeSignal = signal<PlanningOutcome | null>(null); readonly planningOutcomeSignal = signal<PlanningOutcome | null>(null);
readonly planningSnapshotSignal = signal<PlanningSnapshot | null>(null); readonly planningSnapshotSignal = signal<PlanningSnapshot | null>(null);
readonly displayedPlanSignal = computed(() => { readonly displayedPlanSignal = computed(() => {