Exemplo n.º 1
0
  private void composeInvoice(Integer entityId, Integer userId, NewInvoiceDTO newInvoice)
      throws PluggableTaskException, TaskException, SessionInternalError {
    newInvoice.setEntityId(entityId);
    PluggableTaskManager taskManager =
        new PluggableTaskManager(entityId, Constants.PLUGGABLE_TASK_INVOICE_COMPOSITION);
    InvoiceCompositionTask task = (InvoiceCompositionTask) taskManager.getNextClass();
    while (task != null) {
      task.apply(newInvoice, userId);
      task = (InvoiceCompositionTask) taskManager.getNextClass();
    }

    String validationMessage = newInvoice.validate();
    if (validationMessage != null) {
      LOG.error(
          "Composing invoice for entity "
              + entityId
              + " invalid new invoice object: "
              + validationMessage);
      throw new SessionInternalError("NewInvoiceDTO:" + validationMessage);
    }
  }