Skip to content

Commit

Permalink
πŸ› Fix(owner): don't count archived applications (#935)
Browse files Browse the repository at this point in the history
In dashboard, the application number was counting all applications,
including the archived ones. Whereas in the consult property page, only
non-archived applications were listed.
  • Loading branch information
poissoj authored Jan 21, 2025
1 parent 43de031 commit 66c9e63
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import fr.dossierfacile.common.entity.ApartmentSharing;
import fr.dossierfacile.common.entity.Owner;
import fr.dossierfacile.common.entity.Property;
import fr.dossierfacile.common.enums.TenantFileStatus;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.springframework.stereotype.Component;

@Component
Expand All @@ -20,7 +23,15 @@ public abstract class OwnerMapper {
@Mapping( target="totalGuarantorSalary", expression="java(apartmentSharing.totalGuarantorSalary())" )
public abstract ApartmentSharingModel apartmentSharingToApartmentSharingModel(ApartmentSharing apartmentSharing);

@Mapping( target="propertyApartmentSharingCount", expression="java(property.getPropertiesApartmentSharing().size())" )
@Mapping( source="dpeDate", target="dpeDate", dateFormat="yyyy-MM-dd")
@Mapping( source="property", target="propertyApartmentSharingCount", qualifiedByName="validApplicationsCount" )
@Mapping( source="dpeDate", target="dpeDate", dateFormat="yyyy-MM-dd" )
public abstract LightPropertyModel toLightPropertyModel(Property property);

@Named("validApplicationsCount")
public static int getValidApplicationsCount(Property property) {
long count = property.getPropertiesApartmentSharing().stream()
.filter(p -> !p.getApartmentSharing().getStatus().equals(TenantFileStatus.ARCHIVED))
.count();
return (int) count;
}
}

0 comments on commit 66c9e63

Please sign in to comment.