Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix(owner): don't count archived applications #935

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading