class BudgetMapper {

    public BudgetContract toContract(final Budget budget) {

        final BudgetContract contract = new BudgetContract();
        contract.setId(budget.getId());
        contract.setName(budget.getName());
        if (budget.getFinancialYear() != null)
            contract.setFinancialYear(budget.getFinancialYear());
        contract.setEstimationType(
                budget.getEstimationType() != null ? EstimationTypeContract.valueOf(budget.getEstimationType().name()) : null);
        if (budget.getParent() != null)
            contract.setParent(toContract(budget.getParent()));
        contract.setDescription(budget.getDescription());
        contract.setActive(budget.getActive());
        contract.setPrimaryBudget(budget.getPrimaryBudget());
        contract.setMaterializedPath(budget.getMaterializedPath());
        if (budget.getReferenceBudget() != null)
            contract.setReferenceBudget(toContract(budget.getReferenceBudget()));
        contract.setDocumentNumber(budget.getDocumentNumber());
        if (budget.getStatus() != null)
            contract.setStatus(FinancialStatusContract.builder().id(budget.getStatus().getId())
                    .code(budget.getStatus().getCode()).description(budget.getStatus().getDescription())
                    .moduleType(budget.getStatus().getModuleType()).build());
        contract.setCreatedBy(budget.getCreatedBy());
        contract.setCreatedDate(budget.getCreatedDate());
        contract.setLastModifiedBy(budget.getLastModifiedBy());
        contract.setLastModifiedDate(budget.getLastModifiedDate());
        contract.setTenantId(budget.getTenantId());

        return contract;
    }

}