package dev.lions.unionflow.server.mapper.mutuelle.credit;

import dev.lions.unionflow.server.api.dto.mutuelle.credit.EcheanceCreditDTO;
import dev.lions.unionflow.server.entity.mutuelle.credit.EcheanceCredit;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

@Mapper(componentModel = "cdi", builder = @org.mapstruct.Builder(disableBuilder = true))
public interface EcheanceCreditMapper {

    @Mapping(target = "demandeCreditId", source = "demandeCredit.id")
    EcheanceCreditDTO toDto(EcheanceCredit entity);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "dateCreation", ignore = true)
    @Mapping(target = "dateModification", ignore = true)
    @Mapping(target = "creePar", ignore = true)
    @Mapping(target = "modifiePar", ignore = true)
    @Mapping(target = "version", ignore = true)
    @Mapping(target = "actif", ignore = true)
    @Mapping(target = "demandeCredit", ignore = true)
    EcheanceCredit toEntity(EcheanceCreditDTO dto);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "dateCreation", ignore = true)
    @Mapping(target = "dateModification", ignore = true)
    @Mapping(target = "creePar", ignore = true)
    @Mapping(target = "modifiePar", ignore = true)
    @Mapping(target = "version", ignore = true)
    @Mapping(target = "actif", ignore = true)
    @Mapping(target = "demandeCredit", ignore = true)
    void updateEntityFromDto(EcheanceCreditDTO dto, @MappingTarget EcheanceCredit entity);
}
