class BudgetDetailMapper {

    public BudgetDetail toDomain(final BudgetDetailContract contract) {

        final BudgetDetail budgetDetail = new BudgetDetail();

        budgetDetail.setId(contract.getId());
        budgetDetail.setBudgetGroup(contract.getBudgetGroup());
        final Budget budget = Budget.builder().id(contract.getBudget() != null ? contract.getBudget().getId() : null).build();
        budget.setTenantId(contract.getBudget() != null ? contract.getBudget().getTenantId() : null);
        budgetDetail.setBudget(budget);
        budgetDetail.setOriginalAmount(contract.getOriginalAmount());
        budgetDetail.setApprovedAmount(contract.getApprovedAmount());
        budgetDetail.setBudgetAvailable(contract.getBudgetAvailable());
        budgetDetail.setAnticipatoryAmount(contract.getAnticipatoryAmount());
        budgetDetail.setUsingDepartment(contract.getUsingDepartment());
        budgetDetail.setExecutingDepartment(contract.getUsingDepartment());
        budgetDetail.setFunction(contract.getFunction());
        budgetDetail.setScheme(contract.getScheme());
        budgetDetail.setFund(contract.getFund());
        budgetDetail.setSubScheme(contract.getSubScheme());
        budgetDetail.setFunctionary(contract.getFunctionary());
        budgetDetail.setBoundary(contract.getBoundary());
        budgetDetail.setMaterializedPath(contract.getMaterializedPath());
        budgetDetail.setDocumentNumber(contract.getDocumentNumber());
        budgetDetail.setUniqueNo(contract.getUniqueNo());
        budgetDetail.setPlanningPercent(contract.getPlanningPercent());
        budgetDetail.setStatus(FinancialStatusContract.builder()
                .id(contract.getStatus() != null ? contract.getStatus().getId() : null).build());
        budgetDetail.setCreatedBy(contract.getCreatedBy());
        budgetDetail.setCreatedDate(contract.getCreatedDate());
        budgetDetail.setLastModifiedBy(contract.getLastModifiedBy());
        budgetDetail.setLastModifiedDate(contract.getLastModifiedDate());
        budgetDetail.setTenantId(contract.getTenantId());

        return budgetDetail;
    }

}