class BudgetMapper {

    public BudgetSearch toSearchDomain(final BudgetSearchContract contract) {

        final BudgetSearch budgetSearch = new BudgetSearch();

        budgetSearch.setId(contract.getId());
        budgetSearch.setName(contract.getName());
        budgetSearch.setFinancialYear(contract.getFinancialYear());
        budgetSearch.setEstimationType(
                contract.getEstimationType() != null ? EstimationType.valueOf(contract.getEstimationType().name()) : null);
        budgetSearch.setParent(
                Budget.builder().id(contract.getParent() != null ? contract.getParent().getId() : null).build());
        budgetSearch.setDescription(contract.getDescription());
        budgetSearch.setActive(contract.getActive());
        budgetSearch.setPrimaryBudget(contract.getPrimaryBudget());
        budgetSearch.setMaterializedPath(contract.getMaterializedPath());
        budgetSearch.setReferenceBudget(Budget.builder()
                .id(contract.getReferenceBudget() != null ? contract.getReferenceBudget().getId() : null).build());
        budgetSearch.setDocumentNumber(contract.getDocumentNumber());
        budgetSearch.setStatus(FinancialStatusContract.builder()
                .id(contract.getStatus() != null ? contract.getStatus().getId() : null).build());
        budgetSearch.setCreatedBy(contract.getCreatedBy());
        budgetSearch.setCreatedDate(contract.getCreatedDate());
        budgetSearch.setLastModifiedBy(contract.getLastModifiedBy());
        budgetSearch.setLastModifiedDate(contract.getLastModifiedDate());
        budgetSearch.setTenantId(contract.getTenantId());
        budgetSearch.setPageSize(contract.getPageSize());
        budgetSearch.setOffset(contract.getOffset());

        return budgetSearch;
    }

}