public ProjectStatusReportDTO(OrderElement orderElement, Order orderToAppendName) {
    code = orderElement.getCode();

    if (orderToAppendName != null) {
      name = orderElement.getName() + " (" + orderToAppendName.getName() + ")";
    } else {
      name = Util.getPrefixSpacesDependingOnDepth(orderElement) + orderElement.getName();
    }

    Integer estimatedHours = orderElement.getWorkHours();
    this.estimatedHours = estimatedHours != null ? EffortDuration.hours(estimatedHours) : null;

    TaskSource taskSource = orderElement.getTaskSource();
    if (taskSource != null) {
      plannedHours = taskSource.getTask().getSumOfAssignedEffort();
    }

    SumChargedEffort sumChargedEffort = orderElement.getSumChargedEffort();
    if (sumChargedEffort != null) {
      imputedHours = sumChargedEffort.getTotalChargedEffort();
    }

    setBudget(orderElement.getSubstractedBudget());

    setExpensesBudget(orderElement.getBudget());
    setResourcesBudget(orderElement.getResourcesBudget());
  }
  @Test
  @Transactional
  public void validSubcontractedTaskData() {
    int previous = orderDAO.getOrders().size();

    String orderLineCode = "order-line-code";

    OrderElementDTO orderElementDTO = givenBasicOrderLineDTO(orderLineCode);
    ExternalCompany externalCompany = getClientExternalCompanySaved("Company", "company-nif");

    SubcontractedTaskDataDTO subcontractedTaskDataDTO = new SubcontractedTaskDataDTO();
    subcontractedTaskDataDTO.orderElementDTO = orderElementDTO;
    subcontractedTaskDataDTO.externalCompanyNif = externalCompany.getNif();

    String orderName = "Work description";
    String orderCustomerReference = "client-reference-code";
    BigDecimal orderBudget = new BigDecimal(1000).setScale(2);
    subcontractedTaskDataDTO.workDescription = orderName;
    subcontractedTaskDataDTO.subcontractedCode = orderCustomerReference;
    subcontractedTaskDataDTO.subcontractPrice = orderBudget;

    List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList =
        subcontractService.subcontract(subcontractedTaskDataDTO).instanceConstraintViolationsList;
    assertThat(instanceConstraintViolationsList.size(), equalTo(0));

    assertThat(orderDAO.getOrders().size(), equalTo(previous + 1));

    Order order = orderDAO.getOrders().get(previous);
    assertNotNull(order.getCode());
    assertTrue(order.isCodeAutogenerated());
    assertNotNull(order.getExternalCode());
    assertThat(order.getExternalCode(), equalTo(orderLineCode));
    assertThat(order.getState(), equalTo(OrderStatusEnum.OUTSOURCED));
    assertThat(order.getWorkHours(), equalTo(0));
    assertThat(order.getCustomer().getId(), equalTo(externalCompany.getId()));
    assertThat(order.getName(), equalTo(orderName));
    assertThat(order.getCustomerReference(), equalTo(orderCustomerReference));
    assertThat(order.getTotalManualBudget(), equalTo(orderBudget));

    List<OrderElement> children = order.getChildren();
    assertThat(children.size(), equalTo(1));
    assertNull(children.get(0).getExternalCode());
  }