diff --git a/frontend/src/app/components/lease-card/lease-card.html b/frontend/src/app/components/lease-card/lease-card.html index 08b868c..b8678e4 100644 --- a/frontend/src/app/components/lease-card/lease-card.html +++ b/frontend/src/app/components/lease-card/lease-card.html @@ -1,119 +1,70 @@
-
- {{ statusLabel() }}{{ lease().monthlyRent.toLocaleString('fr-FR') }} € -
-

{{ apartmentName() }}

-

{{ tenantNames() }}

-
-
-
Période
-
- {{ lease().startDate | date: 'dd MMMM yyyy' }} → - {{ lease().endDate | date: 'dd MMMM yyyy' }} -
-
-
-
Charges
-
{{ lease().monthlyCharges.toLocaleString('fr-FR') }} € / mois
-
-
-
Dépôt
-
{{ lease().securityDeposit.toLocaleString('fr-FR') }} €
-
-
- @if (lease().guarantors.length) { -
- Garant - @for (guarantor of lease().guarantors; track $index) { - {{ guarantor.firstName }} {{ guarantor.lastName }} - } -
- } - @if (rentDues().length) { -
-

Échéancier

- @for (rentDue of rentDues(); track rentDue.id) { -
- {{ rentDue.month }} -
-
-
Loyer
-
{{ rentDue.rent.toLocaleString('fr-FR') }} €
-
-
-
Charges
-
{{ rentDue.charges.toLocaleString('fr-FR') }} €
-
-
-
Total
-
{{ rentDue.total.toLocaleString('fr-FR') }} €
-
-
-
Restant
-
{{ rentDue.remainingAmount.toLocaleString('fr-FR') }} €
-
-
-
- Règlement : {{ settlementLabel(rentDue.settlement) }} - Temporalité : {{ timingLabel(rentDue.timing) }} -
-
- } -
- } - @if (deleteError() || downloadError() || activationError()) { - - } -
- - @if (lease().id && lease().status === 'DRAFT') { - - - - } -
-
+
+ {{ statusLabel() }}{{ + lease().monthlyRent.toLocaleString('fr-FR') }} € +
+

{{ apartmentName() }}

+

{{ tenantNames() }}

+
+
+
Période
+
+ {{ lease().startDate | date: 'dd MMMM yyyy' }} → + {{ lease().endDate | date: 'dd MMMM yyyy' }} +
+
+
+
Charges
+
{{ lease().monthlyCharges.toLocaleString('fr-FR') }} € / mois
+
+
+
Dépôt
+
{{ lease().securityDeposit.toLocaleString('fr-FR') }} €
+
+
+ @if (lease().guarantors.length) { +
+ Garant + @for (guarantor of lease().guarantors; track $index) { + {{ guarantor.firstName }} {{ guarantor.lastName }} + } +
+ } + @if (deleteError() || downloadError() || activationError()) { + + } +
+ + @if (lease().id && lease().status === 'DRAFT') { + + + + } +
+ \ No newline at end of file diff --git a/frontend/src/app/components/lease-card/lease-card.spec.ts b/frontend/src/app/components/lease-card/lease-card.spec.ts index 5c43664..1cad918 100644 --- a/frontend/src/app/components/lease-card/lease-card.spec.ts +++ b/frontend/src/app/components/lease-card/lease-card.spec.ts @@ -115,45 +115,4 @@ describe('LeaseCard', () => { expect(fixture.nativeElement.textContent).not.toContain('Activer'); }); - it('shows the resulting rent schedule with separate settlement and timing labels', () => { - const fixture = TestBed.createComponent(LeaseCard); - fixture.componentRef.setInput('apartments', []); - fixture.componentRef.setInput('tenants', []); - fixture.componentRef.setInput('lease', { - id: 'lease-1', - apartmentId: 'apartment-1', - tenantIds: [], - guarantors: [], - startDate: '2026-01-01', - endDate: '2026-01-31', - monthlyRent: 800, - monthlyCharges: 50, - securityDeposit: 800, - status: 'ACTIVE', - }); - fixture.componentRef.setInput('rentDues', [ - { - id: 'due-1', - leaseId: 'lease-1', - month: '2026-01', - dueDate: '2026-01-01', - rent: 800, - charges: 50, - total: 850, - remainingAmount: 850, - settlement: 'UNPAID', - timing: 'OVERDUE', - }, - ]); - fixture.detectChanges(); - - const text = fixture.nativeElement.textContent.replace(/\s+/g, ' '); - const amounts = [...fixture.nativeElement.querySelectorAll('.rent-due dl div')].map((term) => - [...term.children].map((item) => item.textContent.trim()).join(' '), - ); - expect(text).toContain('2026-01'); - expect(amounts).toEqual(['Loyer 800 €', 'Charges 50 €', 'Total 850 €', 'Restant 850 €']); - expect(text).toContain('Règlement : Non réglée'); - expect(text).toContain('Temporalité : En retard'); - }); }); diff --git a/frontend/src/app/components/lease-card/lease-card.ts b/frontend/src/app/components/lease-card/lease-card.ts index 2655561..6baf5ee 100644 --- a/frontend/src/app/components/lease-card/lease-card.ts +++ b/frontend/src/app/components/lease-card/lease-card.ts @@ -48,14 +48,4 @@ export class LeaseCard { this.lease().status ]; } - - settlementLabel(settlement: RentDue['settlement']): string { - return { UNPAID: 'Non réglée', PARTIALLY_PAID: 'Partiellement réglée', PAID: 'Réglée' }[ - settlement - ]; - } - - timingLabel(timing: RentDue['timing']): string { - return { UPCOMING: 'À venir', OVERDUE: 'En retard' }[timing]; - } } diff --git a/frontend/src/app/components/leases-page/leases-page.spec.ts b/frontend/src/app/components/leases-page/leases-page.spec.ts index 1610169..392db19 100644 --- a/frontend/src/app/components/leases-page/leases-page.spec.ts +++ b/frontend/src/app/components/leases-page/leases-page.spec.ts @@ -107,71 +107,4 @@ describe('LeasesPage', () => { expect(workspace.loadRentDues).toHaveBeenCalledOnce(); }); - it('renders each échéance only under its matching bail', () => { - workspace.apartmentLoadState.set({ loaded: true, loading: false, error: '' }); - workspace.tenantLoadState.set({ loaded: true, loading: false, error: '' }); - workspace.leaseLoadState.set({ loaded: true, loading: false, error: '' }); - workspace.rentDueLoadState.set({ loaded: true, loading: false, error: '' }); - workspace.leases.set([ - { - id: 'lease-1', - apartmentId: 'apartment-1', - tenantIds: [], - guarantors: [], - startDate: '2026-01-01', - endDate: '2026-12-31', - monthlyRent: 800, - monthlyCharges: 50, - securityDeposit: 800, - status: 'ACTIVE', - }, - { - id: 'lease-2', - apartmentId: 'apartment-2', - tenantIds: [], - guarantors: [], - startDate: '2027-01-01', - endDate: '2027-12-31', - monthlyRent: 900, - monthlyCharges: 60, - securityDeposit: 900, - status: 'ACTIVE', - }, - ]); - workspace.rentDues.set([ - { - id: 'due-1', - leaseId: 'lease-1', - month: '2026-01', - dueDate: '2026-01-01', - rent: 800, - charges: 50, - total: 850, - remainingAmount: 850, - settlement: 'UNPAID', - timing: 'OVERDUE', - }, - { - id: 'due-2', - leaseId: 'lease-2', - month: '2027-01', - dueDate: '2027-01-01', - rent: 900, - charges: 60, - total: 960, - remainingAmount: 960, - settlement: 'UNPAID', - timing: 'UPCOMING', - }, - ]); - const fixture = TestBed.createComponent(LeasesPage); - fixture.detectChanges(); - - const cards = fixture.nativeElement.querySelectorAll('.lease-card'); - expect(cards).toHaveLength(2); - expect(cards[0].textContent).toContain('2026-01'); - expect(cards[0].textContent).not.toContain('2027-01'); - expect(cards[1].textContent).toContain('2027-01'); - expect(cards[1].textContent).not.toContain('2026-01'); - }); });