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

import dev.lions.unionflow.server.api.dto.mutuelle.epargne.CompteEpargneRequest;
import dev.lions.unionflow.server.api.dto.mutuelle.epargne.CompteEpargneResponse;
import dev.lions.unionflow.server.entity.mutuelle.epargne.CompteEpargne;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

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

    @Mapping(target = "membreId", source = "membre.id")
    @Mapping(target = "organisationId", source = "organisation.id")
    CompteEpargneResponse toDto(CompteEpargne 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 = "membre", ignore = true)
    @Mapping(target = "organisation", ignore = true)
    @Mapping(target = "numeroCompte", ignore = true)
    @Mapping(target = "soldeActuel", ignore = true)
    @Mapping(target = "soldeBloque", ignore = true)
    @Mapping(target = "statut", ignore = true)
    @Mapping(target = "dateOuverture", ignore = true)
    @Mapping(target = "dateDerniereTransaction", ignore = true)
    @Mapping(target = "description", source = "notesOuverture")
    CompteEpargne toEntity(CompteEpargneRequest request);

    @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 = "membre", ignore = true)
    @Mapping(target = "organisation", ignore = true)
    @Mapping(target = "numeroCompte", ignore = true)
    @Mapping(target = "soldeActuel", ignore = true)
    @Mapping(target = "soldeBloque", ignore = true)
    @Mapping(target = "statut", ignore = true)
    @Mapping(target = "dateOuverture", ignore = true)
    @Mapping(target = "dateDerniereTransaction", ignore = true)
    @Mapping(target = "description", source = "notesOuverture")
    void updateEntityFromDto(CompteEpargneRequest request, @MappingTarget CompteEpargne entity);
}
