package vn.azteam.tpf.service.mapper;

import vn.azteam.tpf.domain.*;
import vn.azteam.tpf.service.dto.TBStockUpdateDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity TBStockUpdate and its DTO TBStockUpdateDTO.
 */
@Mapper(componentModel = "spring", uses = {
    TBSuppliesOrderMapper.class,
    TBSuppliesInWarehouseMapper.class,
    TBActivityMapper.class,
    TBBlockDetailsMapper.class
})
public interface TBStockUpdateMapper extends EntityMapper<TBStockUpdateDTO, TBStockUpdate> {

    @Mapping(source = "tbBlockDetails.id", target = "tbBlockDetailsId")
    @Mapping(source = "tbBlockDetails.code", target = "tbBlockDetailsCode")
    @Mapping(source = "tbSuppliesOrder.id", target = "tbSuppliesOrderId")
    @Mapping(source = "tbActivity.id", target = "tbActivityId")
    @Mapping(source = "tbSuppliesInWarehouse.id", target = "tbSuppliesInWarehouseId")
    @Mapping(source = "tbSuppliesInWarehouse.tbEntity.name", target = "tbEntityName")
    @Mapping(source = "tbSuppliesInWarehouse.tbSupplies.tbCustomer.id", target = "tbCustomerId")
    TBStockUpdateDTO toDto(TBStockUpdate tBStockUpdate);

    @Mapping(source = "tbBlockDetailsId", target = "tbBlockDetails")
    @Mapping(source = "tbSuppliesOrderId", target = "tbSuppliesOrder")
    @Mapping(source = "tbActivityId", target = "tbActivity")
    @Mapping(source = "tbSuppliesInWarehouseId", target = "tbSuppliesInWarehouse")
    TBStockUpdate toEntity(TBStockUpdateDTO tBStockUpdateDTO);

    default TBStockUpdate fromId(Long id) {
        if (id == null) {
            return null;
        }
        TBStockUpdate tBStockUpdate = new TBStockUpdate();
        tBStockUpdate.setId(id);
        return tBStockUpdate;
    }
}
