/**
   * This removes a item from the current transaction.
   *
   * @param barcode the item's barcode number.
   * @throws IllegalStateException if there are no items on the invoice to remove.
   */
  public void removeItem(String barcode) throws IllegalStateException {
    int itemCount = myTransaction.getNumberOfItems();
    if (itemCount == 0) {
      throw new IllegalStateException("There are no items on the Invoice.");
    }

    // compare each item that is currently on the invoice with the barcode given
    boolean found = false;
    int line = 1; // the line in the invoice where this item is, start looking on line 1.
    for (line = 1; line <= itemCount; line++) {
      TransactionItem itemOnInvoice = myTransaction.getItem(line);
      if (itemOnInvoice.getBarcode() == barcode) {
        found = true;
        break;
      }
    }
    if (!found) throw new IllegalStateException("Item not in list");
    else myTransaction.removeTransactionItem(line);
  }
 /**
  * This adds/saves the current transaction to the database.
  *
  * @throws IllegalStateException if the transaction has not been paid for.
  *     <dt><b>Precondition:</b>
  *     <dd>
  *         <ul>
  *           <li>Payment for the transaction has been made.
  *         </ul>
  */
 public void process()
     throws IllegalStateException, SQLException, ClassNotFoundException, MovieNotFoundException,
         Exception {
   if (myTransaction.isPaid() == false) {
     throw new IllegalStateException("The invoice has not been paid, not saving info.");
   }
   // mySQLhelper.insertInvoiceTable(myTransaction);
   RentalMovieManagement rentalManager = new RentalMovieManagement();
   SaleMovieManagement saleManager = new SaleMovieManagement();
   for (int i = 1; i <= myTransaction.getNumberOfItems(); i++) {
     TransactionItem item = myTransaction.getItem(i);
     if (item.getType().equals("for sale")) {
       saleManager.sell(item.getBarcode());
     } else if (item.getType().trim().toLowerCase().equals("new release")
         || item.getType().trim().toLowerCase().equals("7 day")) {
       rentalManager.checkOut(
           myTransaction.getCustomerID(), item.getBarcode(), new JDBCConnection());
     }
   }
 }