class BudgetDetailMapper {

    public BudgetDetailContract toContract(final BudgetDetail budgetDetail) {

        final BudgetDetailContract contract = new BudgetDetailContract();

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

        return contract;
    }

}