feat: activate draft leases into rent dues (#28)
This commit is contained in:
1 parent
971ffd6feb
commit
c2afe515c0
42 files changed
+1735
-113
No files matched your search
@@ -18,12 +18,84 @@ describe('LeaseForm', () => {
|
||||
monthlyCharges: 50,
|
||||
securityDeposit: 850,
|
||||
});
|
||||
let startDate = '';
|
||||
component.submitted.subscribe((lease) => (startDate = lease.startDate));
|
||||
let submitted: unknown;
|
||||
component.submitted.subscribe((lease) => (submitted = lease));
|
||||
|
||||
component.save();
|
||||
|
||||
expect(startDate).toBe('2026-09-01');
|
||||
expect(submitted).toEqual({
|
||||
apartmentId: 'apartment-1',
|
||||
tenantIds: ['tenant-1'],
|
||||
guarantors: [],
|
||||
startDate: '2026-09-01',
|
||||
endDate: '2027-08-31',
|
||||
monthlyRent: 850,
|
||||
monthlyCharges: 50,
|
||||
securityDeposit: 850,
|
||||
});
|
||||
});
|
||||
|
||||
it('allows overlapping draft dates but leaves active dates unavailable', () => {
|
||||
TestBed.configureTestingModule({ providers: [provideNativeDateAdapter()] });
|
||||
const fixture = TestBed.createComponent(LeaseForm);
|
||||
fixture.componentRef.setInput('apartments', []);
|
||||
fixture.componentRef.setInput('tenants', []);
|
||||
fixture.componentRef.setInput('leases', [
|
||||
{
|
||||
id: 'draft-1',
|
||||
apartmentId: 'apartment-1',
|
||||
tenantIds: [],
|
||||
guarantors: [],
|
||||
startDate: '2026-01-01',
|
||||
endDate: '2026-01-31',
|
||||
monthlyRent: 800,
|
||||
monthlyCharges: 50,
|
||||
securityDeposit: 800,
|
||||
status: 'DRAFT',
|
||||
},
|
||||
{
|
||||
id: 'active-1',
|
||||
apartmentId: 'apartment-1',
|
||||
tenantIds: [],
|
||||
guarantors: [],
|
||||
startDate: '2026-02-01',
|
||||
endDate: '2026-02-28',
|
||||
monthlyRent: 800,
|
||||
monthlyCharges: 50,
|
||||
securityDeposit: 800,
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
]);
|
||||
fixture.componentInstance.leaseModel.update((lease) => ({
|
||||
...lease,
|
||||
apartmentId: 'apartment-1',
|
||||
}));
|
||||
|
||||
expect(fixture.componentInstance.dateFilter(new Date(2026, 0, 15))).toBe(true);
|
||||
expect(fixture.componentInstance.dateFilter(new Date(2026, 1, 15))).toBe(false);
|
||||
});
|
||||
|
||||
it('loads a draft for editing', () => {
|
||||
TestBed.configureTestingModule({ providers: [provideNativeDateAdapter()] });
|
||||
const fixture = TestBed.createComponent(LeaseForm);
|
||||
fixture.componentRef.setInput('apartments', []);
|
||||
fixture.componentRef.setInput('tenants', []);
|
||||
fixture.componentRef.setInput('lease', {
|
||||
id: 'draft-1',
|
||||
apartmentId: 'apartment-1',
|
||||
tenantIds: ['tenant-1'],
|
||||
guarantors: [],
|
||||
startDate: '2026-09-01',
|
||||
endDate: '2027-08-31',
|
||||
monthlyRent: 850,
|
||||
monthlyCharges: 50,
|
||||
securityDeposit: 850,
|
||||
status: 'DRAFT',
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.componentInstance.leaseModel().apartmentId).toBe('apartment-1');
|
||||
expect(fixture.nativeElement.textContent).toContain('Modifier le brouillon');
|
||||
});
|
||||
|
||||
it('keeps guarantors in the lease form module', () => {
|
||||
|
||||
Reference in new issue
Block a user