fix: preserve entry summary inventory facts (#62)
This commit is contained in:
1 parent
153d905052
commit
615429dc1c
5 files changed
+59
-35
No files matched your search
+1
-9
@@ -7,13 +7,13 @@ import {
|
||||
ConditionReportComparison,
|
||||
ConditionReportComparisonLine,
|
||||
ConditionReportService,
|
||||
ConditionState,
|
||||
ConditionZone,
|
||||
InventoryCondition,
|
||||
MeterReading,
|
||||
PropertyConditionReportSupplement,
|
||||
} from '../../services/condition-report.service';
|
||||
import { httpErrorMessage } from '../../services/http-error-message';
|
||||
import { conditionReportStateLabels as stateLabels } from './condition-report-state-label';
|
||||
|
||||
@Component({
|
||||
selector: 'app-condition-report-comparison-section',
|
||||
@@ -83,14 +83,6 @@ function comparisonSection<T>(
|
||||
})),
|
||||
};
|
||||
}
|
||||
const stateLabels: Record<ConditionState, string> = {
|
||||
NEUF: 'Neuf',
|
||||
BON_ETAT: 'Bon état',
|
||||
ETAT_USAGE: 'État d’usage',
|
||||
DEGRADE: 'Dégradé',
|
||||
ABSENT: 'Absent',
|
||||
NON_APPLICABLE: 'Non applicable',
|
||||
};
|
||||
function describeObservation(value: ConditionObservation): string {
|
||||
return [stateLabels[value.state], value.observation].filter(Boolean).join(' — ');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { ConditionState } from '../../services/condition-report.service';
|
||||
|
||||
export const conditionReportStateLabels: Record<ConditionState, string> = {
|
||||
NEUF: 'Neuf',
|
||||
BON_ETAT: 'Bon état',
|
||||
ETAT_USAGE: 'État d’usage',
|
||||
DEGRADE: 'Dégradé',
|
||||
ABSENT: 'Absent',
|
||||
NON_APPLICABLE: 'Non applicable',
|
||||
};
|
||||
@@ -62,10 +62,34 @@
|
||||
<ul>
|
||||
@for (item of area.inventory; track item.id) {
|
||||
<li>
|
||||
{{ item.designation }} — {{ item.observedQuantity }} constaté(s),
|
||||
{{ item.contractualQuantity }} au bail{{
|
||||
item.conditions ? ' · ' + item.conditions : ''
|
||||
}}{{ item.description ? ' : ' + item.description : '' }}
|
||||
<strong>{{ item.designation }}</strong>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>Quantité constatée</dt>
|
||||
<dd>{{ item.observedQuantity }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Quantité au bail</dt>
|
||||
<dd>{{ item.contractualQuantity }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Description constatée</dt>
|
||||
<dd>{{ item.observedDescription }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Description au bail</dt>
|
||||
<dd>{{ item.contractualDescription }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
@if (item.splits.length) {
|
||||
<ul aria-label="État constaté">
|
||||
@for (split of item.splits; track $index) {
|
||||
<li>{{ split.condition }} — {{ split.observation }}</li>
|
||||
}
|
||||
</ul>
|
||||
} @else {
|
||||
<p>Aucun état détaillé.</p>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -48,15 +48,15 @@ describe('ConditionReportSummaryComponent', () => {
|
||||
privateAreaLabel: 'Cuisine',
|
||||
designation: 'Chaise',
|
||||
contractualQuantity: 2,
|
||||
contractualDescription: 'Bois',
|
||||
contractualDescription: 'Bois verni',
|
||||
observedQuantity: 1,
|
||||
observedDescription: 'Assise marquée',
|
||||
observedDescription: 'Bois peint',
|
||||
splits: [
|
||||
{
|
||||
inventoryLineId: 'chair',
|
||||
state: 'DEGRADE',
|
||||
quantity: 1,
|
||||
observation: 'Assise marquée',
|
||||
observation: 'Pied rayé',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -91,7 +91,12 @@ describe('ConditionReportSummaryComponent', () => {
|
||||
expect(summary).toContain('Cuisine');
|
||||
expect(summary).toContain('Sol — Bon état');
|
||||
expect(summary).toContain('Climatisation — Dégradé · Climatisation : Filtre à nettoyer');
|
||||
expect(summary).toContain('Chaise — 1 constaté(s), 2 au bail · 1 dégradé : Assise marquée');
|
||||
expect(summary).toContain('Quantité constatée');
|
||||
expect(summary).toContain('Description constatée');
|
||||
expect(summary).toContain('Bois peint');
|
||||
expect(summary).toContain('Description au bail');
|
||||
expect(summary).toContain('Bois verni');
|
||||
expect(summary).toContain('1 dégradé — Pied rayé');
|
||||
expect(summary).toContain('Cave');
|
||||
expect(summary).toContain('Aucune surface ni équipement constaté.');
|
||||
expect(summary).toContain('Compteur entrée — 42 kWh');
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import {
|
||||
AccessMeansType,
|
||||
ConditionState,
|
||||
MeterType,
|
||||
PropertyConditionReport,
|
||||
ZoneEquipment,
|
||||
} from '../../services/condition-report.service';
|
||||
import { conditionReportStateLabels } from './condition-report-state-label';
|
||||
|
||||
type ConditionReportSummary = ReturnType<typeof summarize>;
|
||||
|
||||
const conditionLabels: Record<ConditionState, string> = {
|
||||
NEUF: 'Neuf',
|
||||
BON_ETAT: 'Bon état',
|
||||
ETAT_USAGE: 'État d’usage',
|
||||
DEGRADE: 'Dégradé',
|
||||
ABSENT: 'Absent',
|
||||
NON_APPLICABLE: 'Non applicable',
|
||||
};
|
||||
|
||||
const equipmentLabels: Record<ZoneEquipment, string> = {
|
||||
NONE: 'Aucun équipement',
|
||||
CLIMATISATION: 'Climatisation',
|
||||
@@ -64,7 +55,7 @@ function summarize(report: PropertyConditionReport) {
|
||||
label: zone.label,
|
||||
equipment: zone.equipment === 'NONE' ? '' : equipmentLabels[zone.equipment],
|
||||
condition: observation
|
||||
? conditionLabels[observation.state]
|
||||
? conditionReportStateLabels[observation.state]
|
||||
: 'Non constaté',
|
||||
observation: observation?.observation ?? '',
|
||||
};
|
||||
@@ -76,13 +67,15 @@ function summarize(report: PropertyConditionReport) {
|
||||
designation: item.designation,
|
||||
observedQuantity: item.observedQuantity,
|
||||
contractualQuantity: item.contractualQuantity,
|
||||
description: item.observedDescription || item.contractualDescription,
|
||||
conditions: item.splits
|
||||
.map(
|
||||
(split) =>
|
||||
split.quantity + ' ' + conditionLabels[split.state].toLowerCase(),
|
||||
)
|
||||
.join(', '),
|
||||
observedDescription: item.observedDescription || '—',
|
||||
contractualDescription: item.contractualDescription || '—',
|
||||
splits: item.splits.map((split) => ({
|
||||
condition:
|
||||
split.quantity +
|
||||
' ' +
|
||||
conditionReportStateLabels[split.state].toLowerCase(),
|
||||
observation: split.observation || 'Sans observation.',
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
meters: report.meterReadings.map((meter) => ({
|
||||
|
||||
Reference in new issue
Block a user