private int doInsert() throws BillingServiceException {
      int result = 0;

      for (InvoicedOrderLine invoicedOrderLine : orderLines) {
        try {
          result =
              invoiceCreatedAx
                  .executeFunction(
                      BigDecimal.class,
                      Long.parseLong(invoicedOrderLine.getOrderLine().getOrderLineId()),
                      invoicedOrderLine.getInvoiceId(),
                      invoicedOrderLine.getMarket().getOrganizationId(),
                      invoicedOrderLine.getCurrencyCode().getCurrencyCode(),
                      invoicedOrderLine.getOrderLine().getSystemAgreementId().trim(),
                      invoicedOrderLine.getInvoiceRevenueType())
                  .intValue();
        } catch (NumberFormatException e) {
          // If a number format exception occurs a bug is present and a bugdisturbance should be
          // thrown
          throw BillingServiceException.createBugDisturbance(
              String.format(
                  "Number format exception for order line id : %s",
                  invoicedOrderLine.getOrderLine().getOrderLineId()));
        }

        if (result == -1) {
          failedOrderLine = invoicedOrderLine;
          break;
        }
      }
      return result;
    }
  public void insert(List<InvoicedOrderLine> invoicedOrderLines) throws BillingServiceException {
    TransactionCallback<Integer> insertInvoicedOrderLines =
        new InsertInvoicedOrderLines(invoicedOrderLines, invoiceCreatedAx);
    Integer returnValue;

    try {
      returnValue = transactionTemplate.execute(insertInvoicedOrderLines);
    } catch (TransactionException es) {
      // this could happen, for instance, if the db is unreachable. Therefore throw an integration
      // disturbance
      throw BillingServiceException.createIntegrationDisturbance(es.getMessage());
    }

    if (returnValue == DB_FUNCTION_ERROR_CODE) {
      throw BillingServiceException.createBugDisturbance(
          "BUG_DISTURBANCE : Error when inserting invoiced order lines: "
              + ((InsertInvoicedOrderLines) insertInvoicedOrderLines).getFailedOrderLine());
    }
  }
  /**
   * Confirms that forecasts have been sent to CRM.
   *
   * @param batchId the batch to confirm
   * @throws com.tradedoubler.billing.service.BillingServiceException thrown if database operation
   *     fails
   */
  public void confirm(final Guid batchId) throws BillingServiceException {
    int returnValue =
        updateBatchOfOrderLinesPP
            .executeFunction(BigDecimal.class, batchId.getGuidForOracleDb())
            .intValue();

    if (returnValue == DB_FUNCTION_ERROR_CODE) {
      throw BillingServiceException.createBugDisturbance(
          "Something went wrong when executing stored function billing_pkg.updateBatchOfOrderLines in Pan database"
              + ", batchId: "
              + batchId.getGuidForOracleDb());
    }
  }