class BudgetDetailMapper {

    public BudgetDetailSearch toSearchDomain(final BudgetDetailSearchContract contract) {

        final BudgetDetailSearch budgetDetailSearch = new BudgetDetailSearch();

        budgetDetailSearch.setId(contract.getId());
        budgetDetailSearch.setBudgetGroup(BudgetGroupContract.builder()
                .id(contract.getBudgetGroup() != null ? contract.getBudgetGroup().getId() : null).build());
        budgetDetailSearch.setBudget(
                Budget.builder().id(contract.getBudget() != null ? contract.getBudget().getId() : null).build());
        budgetDetailSearch.setOriginalAmount(contract.getOriginalAmount());
        budgetDetailSearch.setApprovedAmount(contract.getApprovedAmount());
        budgetDetailSearch.setBudgetAvailable(contract.getBudgetAvailable());
        budgetDetailSearch.setAnticipatoryAmount(contract.getAnticipatoryAmount());
        budgetDetailSearch.setUsingDepartment(Department.builder()
                .id(contract.getUsingDepartment() != null ? contract.getUsingDepartment().getId() : null).build());
        budgetDetailSearch.setExecutingDepartment(Department.builder()
                .id(contract.getExecutingDepartment() != null ? contract.getExecutingDepartment().getId() : null)
                .build());
        budgetDetailSearch.setFunction(FunctionContract.builder()
                .id(contract.getFunction() != null ? contract.getFunction().getId() : null).build());
        budgetDetailSearch.setScheme(SchemeContract.builder()
                .id(contract.getScheme() != null ? contract.getScheme().getId() : null).build());
        budgetDetailSearch.setFund(
                FundContract.builder().id(contract.getFund() != null ? contract.getFund().getId() : null).build());
        budgetDetailSearch.setSubScheme(SubSchemeContract.builder()
                .id(contract.getSubScheme() != null ? contract.getSubScheme().getId() : null).build());
        budgetDetailSearch.setFunctionary(FunctionaryContract.builder()
                .id(contract.getFunctionary() != null ? contract.getFunctionary().getId() : null).build());
        budgetDetailSearch.setBoundary(
                Boundary.builder().id(contract.getBoundary() != null ? contract.getBoundary().getId() : null).build());
        budgetDetailSearch.setMaterializedPath(contract.getMaterializedPath());
        budgetDetailSearch.setDocumentNumber(contract.getDocumentNumber());
        budgetDetailSearch.setUniqueNo(contract.getUniqueNo());
        budgetDetailSearch.setPlanningPercent(contract.getPlanningPercent());
        budgetDetailSearch.setStatus(FinancialStatusContract.builder()
                .id(contract.getStatus() != null ? contract.getStatus().getId() : null).build());
        budgetDetailSearch.setCreatedBy(contract.getCreatedBy());
        budgetDetailSearch.setCreatedDate(contract.getCreatedDate());
        budgetDetailSearch.setLastModifiedBy(contract.getLastModifiedBy());
        budgetDetailSearch.setLastModifiedDate(contract.getLastModifiedDate());
        budgetDetailSearch.setTenantId(contract.getTenantId());
        budgetDetailSearch.setPageSize(contract.getPageSize());
        budgetDetailSearch.setOffset(contract.getOffset());

        return budgetDetailSearch;
    }

}